Azure Service Bus Transport Upgrade Version 6 to 7

Topology is mandatory

In Versions 7 and above the topology selection is mandatory:

7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
Edit
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();

transport.UseForwardingTopology();
// OR
transport.UseEndpointOrientedTopology();

The EndpointOrientedTopology is backward compatible with versions 6 and below of the transport. The ForwardingTopology is the recommended option for new projects.

When selecting EndpointOrientedTopology, it is also necessary to configure publisher names, in order to ensure that subscribers are subscribed to the correct publisher:

7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
Edit
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
var topology = transport.UseEndpointOrientedTopology();

topology.RegisterPublisher(typeof(MyMessage), "publisherName");
// OR
var messagesAssembly = Assembly.LoadFrom("path/to/assembly/containing/messages");
topology.RegisterPublisher(messagesAssembly, "publisherName");

For more details on topologies refer to the Azure Service Bus Transport Topologies article.

Sanitization

Azure Service Bus entities have path and name rules that limit the allowed characters and maximum length. NServiceBase derives entity names from endpoint and event names; these derived names may fail Azure Service Bus validation. Sanitization is a process that modifies entity names so that the broker can use them.

In Versions 6 and below sanitization was performed by default and the MD5 algorithm was used to truncate entity names. In Versions 7 and above, the sanitization has to be enabled and configured explicitly.

In order to maintain backward compatibility, register a custom sanitization strategy.

In version 6.4.0 NamingConventions class was introduced to customize sanitization. The class is obsoleted. Instead, implement a custom sanitization strategy.

New Configuration API

In Versions 6 and below the transport was configured using an XML configuration section called AzureServiceBusQueueConfig. This section has been removed in favor of a more granular, code based configuration API.

The new configuration API is accessible through extension methods on the UseTransport<AzureServiceBusTransport>() extension point in the endpoint configuration. Refer to the Full Configuration Page for more details.

Setting The Connection String

Setting the connection string can still be done using the ConnectionString extension method:

7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
Edit
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
transport.ConnectionString("Endpoint=sb://[NAMESPACE].servicebus.windows.net/;SharedAccessKeyName=[KEYNAME];SharedAccessKey=[KEY]");

Default value changes

The default values of the following settings have been changed:

  • BatchSize, which had a default value of 1000, is replaced by PrefetchCount with a default value of 200.
  • MaxDeliveryCount is set to number of immediate retries + 1. For system queues the value has changed from 6 to 10.

For more details refer to the ASB Batching and ASB Retry behavior articles.

Setting Entity Property Values

The other configuration properties found on AzureServiceBusQueueConfig were related to the configuration of Azure Service Bus entities. Even though the name implied differently, these settings were not only applied to queues, but also to topics and subscriptions.

In the new configuration API the settings for queues, topics and subscriptions can be configured individually using the Queues(), Topics() and Subscriptions() extension points.

For example the lock duration on a queue can be configured using the LockDuration setting:

7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
Edit
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
var queues = transport.Queues();
queues.LockDuration(TimeSpan.FromMinutes(1));

and the size of the topics can be configured using the MaxSizeInMegabytes setting:

7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
Edit
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
var topics = transport.Topics();
topics.MaxSizeInMegabytes(SizeInMegabytes.Size5120);

Securing Credentials

All endpoints need to be upgraded to Version 7 prior to enabling this feature. Older versions of the transport cannot use namespace names.

In order to enhance security and to avoid sharing sensitive information using UseNamespaceNameInsteadOfConnectionString feature follow the next steps:

  • Upgrade all endpoints to Version 7 or above. Previous versions of transport aren't able to understand namespace name instead of connection string.
  • After the above has been done and all endpoints deployed configure each endpoint switching on UseNamespaceNameInsteadOfConnectionString feature and re-deploy.

BrokeredMessage conventions

In versions 6 and below, BrokeredMessage conventions were specified using BrokeredMessageBodyConversion class. In versions 7 and above, it has been replaced by configuration API.

Related Articles


Last modified