Azure ServiceBus Naming Conventions Extensibility

270 views
Skip to first unread message

Adam Tybor

unread,
Oct 6, 2015, 2:50:32 PM10/6/15
to Particular Software
Helpful information to include
Product 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






Yves Goeleven

unread,
Oct 6, 2015, 3:36:47 PM10/6/15
to Particular Software
Hi Adam,

The idea is that you implement your own ITopology, using your own naming conventions. Feel free to copy paste whatever you need from the default topology and adjust where needed.

In vnext we will take this topology concept a lot further and provide you (non static) configuration capabilities for all aspects related to it.

Hope this will help?

Kind regards,
Yves

Sean Feldman

unread,
Oct 6, 2015, 3:48:06 PM10/6/15
to Particular Software
Hi Adam,

As Yves pointed out, vNext of ASB will be very flexible in terms of configurations and extension points. 
This is great feedback! 
Please keep it coming and bring these issues up so that we can review and discuss what are the specific steps we're taking with the transport to allow better story when NSB 6 will be released.

Adam Tybor

unread,
Oct 8, 2015, 1:41:19 AM10/8/15
to Particular Software
Its not possible to create my own ITopology.  The default topology feature is responsible for configuring all the transport components as well as configuring the topology.  If I create my own topology I have no way of registering the transport components because they are all internal.


How can I do this without rewriting the entire transport, I just need a topology with some custom naming conventions and a custom NamespaceManager Factory to use our own custom Token Provider for service bus connections.

Adam

Yves Goeleven

unread,
Oct 8, 2015, 3:58:14 AM10/8/15
to Particular Software
I see,

We will create a new version where those extension points are open again.

Stay tuned,
Yves
Reply all
Reply to author
Forward
0 new messages