forked from Particular/NServiceBus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yvesgoeleven
committed
Aug 20, 2011
1 parent
1da570a
commit b1d9b57
Showing
9 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...e/Queueing/NServiceBus.Unicast.Queuing.Azure.Config/IndividualQueueConfigurationSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Microsoft.WindowsAzure.ServiceRuntime; | ||
using NServiceBus.Config.ConfigurationSource; | ||
|
||
namespace NServiceBus.Config | ||
{ | ||
public class IndividualQueueConfigurationSource : IConfigurationSource | ||
{ | ||
private readonly IConfigurationSource innerSource; | ||
|
||
public IndividualQueueConfigurationSource(IConfigurationSource innerSource) | ||
{ | ||
this.innerSource = innerSource; | ||
} | ||
|
||
T IConfigurationSource.GetConfiguration<T>() | ||
{ | ||
var config = innerSource.GetConfiguration<T>(); | ||
|
||
var unicastBusConfig = config as UnicastBusConfig; | ||
if (unicastBusConfig != null && unicastBusConfig.LocalAddress != null && RoleEnvironment.IsAvailable) | ||
{ | ||
var individualQueueName = ParseQueueNameFrom(unicastBusConfig.LocalAddress) | ||
+ "-" | ||
+ ParseIndexFrom(RoleEnvironment.CurrentRoleInstance.Id); | ||
if (unicastBusConfig.LocalAddress.Contains("@")) | ||
individualQueueName += "@" + ParseMachineNameFrom(unicastBusConfig.LocalAddress); | ||
|
||
unicastBusConfig.LocalAddress = individualQueueName; | ||
} | ||
|
||
var msmqTransportConfig = config as MsmqTransportConfig; | ||
if (msmqTransportConfig != null && msmqTransportConfig.InputQueue != null && RoleEnvironment.IsAvailable) | ||
{ | ||
var individualQueueName = ParseQueueNameFrom(msmqTransportConfig.InputQueue) | ||
+ "-" | ||
+ ParseIndexFrom(RoleEnvironment.CurrentRoleInstance.Id); | ||
if (msmqTransportConfig.InputQueue.Contains("@")) | ||
individualQueueName += "@" + ParseMachineNameFrom(msmqTransportConfig.InputQueue); | ||
|
||
msmqTransportConfig.InputQueue = individualQueueName; | ||
} | ||
|
||
return config; | ||
} | ||
|
||
private string ParseMachineNameFrom(string inputQueue) | ||
{ | ||
return inputQueue.Contains("@") ? inputQueue.Substring(inputQueue.IndexOf("@") + 1) : string.Empty; | ||
} | ||
|
||
private object ParseQueueNameFrom(string inputQueue) | ||
{ | ||
return inputQueue.Contains("@") ? inputQueue.Substring(0, inputQueue.IndexOf("@")) : inputQueue; | ||
} | ||
|
||
private static int ParseIndexFrom(string id) | ||
{ | ||
var idArray = id.Split('.'); | ||
int index; | ||
if (!int.TryParse((idArray[idArray.Length - 1]), out index)) | ||
{ | ||
idArray = id.Split('_'); | ||
index = int.Parse((idArray[idArray.Length - 1])); | ||
} | ||
return index; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters