Helpful information to includeProduct name: NServiceBus.Azure.Transports.WindowsAzureServiceBus
Version: 6.x
We are trying to upgrade from NSB 4.x to 5.x and this also requires an upgrade to ASB Transport 6.x
Our code currently overrides the default naming conventions for mapping NSB Addresses to ASB Entity Paths. The default NSB convention is to use dots as separators and we need to use slashes because of the type of security model we have present on our ASB Namespaces.
MyApp.EndpointName.Events would need to be translated to MyApp/EndpointName/Events
The sample code we use in configuration looks like this.
var defaultQueueNameConvention = AzureServiceBusQueueNamingConvention.Apply;
AzureServiceBusQueueNamingConvention.Apply = x =>
{
return defaultQueueNameConvention(x.Replace('.', '/'));
};
In the 6.x version of the transport this extension point has been made internal and is hidden behind an ITopology. This is all fine and good however there is one more major flaw for us. The Configuration of the Transport assumes you are using the 1 and only topology bundled with the transport and actually makes internal calls during config time to the private naming conventions of the topology. There really is no way for us, without some hacky reflection tricks, to upgrade to the 6.x version of the transport, we would basically have to write our own transport just to support a name change and custom topology. Determine Best Connection String was another component that was made internal and also has no interface exposed, so we would be forced to copy & paste all that logic into our customizations as well.
Any thoughts / ideas on we can upgrade? My thoughts would be to making naming conventions or an "Address Mapper" as a public interface and part of the ITopology, how you get this static code out of the configure is another challenge.
protected override string GetLocalAddress(ReadOnlySettings settings)
{
ServiceBusEnvironment.SystemConnectivity.Mode = (ConnectivityMode) Enum.Parse(typeof (ConnectivityMode), (NServiceBus.SettingsExtentions.GetConfigSection<AzureServiceBusQueueConfig>(settings) ?? new AzureServiceBusQueueConfig()).ConnectivityMode);
string str = settings.HasSetting("NServiceBus.LocalAddress") ? settings.Get<string>("NServiceBus.LocalAddress") : NServiceBus.SettingsExtentions.EndpointName(settings);
return NamingConventions.QueueNamingConvention(settings, (Type) null, str, false);
}
protected override void Configure(FeatureConfigurationContext context, string defaultconnectionString)
{
string machineName = new DeterminesBestConnectionStringForAzureServiceBus(defaultconnectionString).Determine(context.Settings);
try
{
Address.OverrideDefaultMachine(machineName);
}
catch (InvalidOperationException ex)
{
}
}
Thanks,
Adam