Permalink
Browse files

Service bus configuration should handle situations when a username an…

…d password are not provided
  • Loading branch information...
1 parent 9ba6021 commit 08fa6ebc1e7a3674ea2579974eee1d2609faa0a2 @jrusbatch committed Feb 28, 2013
Showing with 41 additions and 12 deletions.
  1. +20 −6 Web/App_Start/MessagingConfig.cs
  2. +21 −6 Worker/Program.cs
@@ -21,10 +21,17 @@ public static void ConfigureServiceBus()
var userInfo = connectionUri.UserInfo;
- var queueUri = connectionUri.ToString().Replace(userInfo + "@", string.Empty);
- var credentials = userInfo.Split(new[] { ':' });
- var username = credentials[0];
- var password = credentials[1];
+ var queueUri = connectionUri.ToString();
+ string username = null;
+ string password = null;
+
+ if (!string.IsNullOrEmpty(userInfo))
+ {
+ queueUri = queueUri.Replace(userInfo + "@", string.Empty);
+ var credentials = userInfo.Split(new[] { ':' });
+ username = credentials[0];
+ password = credentials[1];
+ }
var endpointAddress = string.Format("{0}/{1}", connectionString, queueName);
@@ -34,8 +41,15 @@ public static void ConfigureServiceBus()
{
sbc.UseRabbitMq(x => x.ConfigureHost(new Uri(queueUri), y =>
{
- y.SetUsername(username);
- y.SetPassword(password);
+ if (!string.IsNullOrEmpty(username))
+ {
+ y.SetUsername(username);
+ }
+
+ if (!string.IsNullOrEmpty(password))
+ {
+ y.SetPassword(password);
+ }
}));
sbc.ReceiveFrom(endpointAddress);
View
@@ -53,10 +53,18 @@ private static void ConfigureServiceBus()
var userInfo = connectionUri.UserInfo;
- var queueUri = connectionUri.ToString().Replace(userInfo + "@", string.Empty);
- var credentials = userInfo.Split(new[] { ':' });
- var username = credentials[0];
- var password = credentials[1];
+ var queueUri = connectionUri.ToString();
+ string username = null;
+ string password = null;
+
+ if (!string.IsNullOrEmpty(userInfo))
+ {
+ queueUri = queueUri.Replace(userInfo + "@", string.Empty);
+ var credentials = userInfo.Split(new[] { ':' });
+ username = credentials[0];
+ password = credentials[1];
+ }
+
var endpointAddress = string.Format("{0}/{1}", connectionString, queueName);
@@ -65,8 +73,15 @@ private static void ConfigureServiceBus()
{
sbc.UseRabbitMq(x => x.ConfigureHost(new Uri(queueUri), y =>
{
- y.SetUsername(username);
- y.SetPassword(password);
+ if (!string.IsNullOrEmpty(username))
+ {
+ y.SetUsername(username);
+ }
+
+ if (!string.IsNullOrEmpty(password))
+ {
+ y.SetPassword(password);
+ }
}));
sbc.ReceiveFrom(endpointAddress);
sbc.Subscribe(subs => subs.Handler<EvaluateCodeCommand>(ProcessCommand));

0 comments on commit 08fa6eb

Please sign in to comment.