This is part of the NServiceBus Upgrade Guide from Version 7 to 8, which also includes the following individual upgrade guides for specific components:
Feature Details
- Upgrading the data bus from version 7 to 8
- Dependency Injection changes
- Upgrade NServiceBus downstreams from Version 7 to 8
- Upgrading message contracts from Version 7 to 8
- Upgrade NServiceBus pipeline extensions from Version 7 to 8
- Transport configuration changes
Transports
- Upgrade AmazonSQS Transport Version 5 to 6
- Azure Service Bus Transport Upgrade Version 2 to 3
- Azure Storage Queues Transport Upgrade Version 10 to 11
- MSMQ Transport Upgrade Version 1 to 2
- RabbitMQ Transport Upgrade Version 7 to 8
- SQL Server Transport Upgrade Version 6 to 7
Persistence
Other
Configuring the Azure Service Bus transport
To use the Azure Service Bus transport for NServiceBus, create a new instance of AzureServiceBusTransport
and pass it to EndpointConfiguration.
.
Instead of:
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
transport.ConnectionString(connectionString);
Use:
var transport = new AzureServiceBusTransport(connectionString);
endpointConfiguration.UseTransport(transport);
UseTransport<T>()
is supported for NServiceBus version 8 via a shim API to ease migration to the new version. However, it is recommended to switch to the new transport configuration API to prepare for future upgrades of NServiceBus.Configuration options
The Azure Service Bus transport configuration options have been moved to the AzureServiceBusTransport
class. See the following table for further information:
Version 2 configuration option | Version 3 configuration option |
---|---|
TopicName | TopicName |
EntityMaximumSize | EntityMaximumSize |
EnablePartitioning | EnablePartitioning |
PrefetchMultiplier | PrefetchMultiplier |
PrefetchCount | PrefetchCount |
TimeToWaitBeforeTriggeringCircuitBreaker | TimeToWaitBeforeTriggeringCircuitBreaker |
SubscriptionNameShortener | SubscriptionNamingConvention |
SubscriptionNamingConvention | SubscriptionNamingConvention |
RuleNameShortener | SubscriptionRuleNamingConvention |
SubscriptionRuleNamingConvention | SubscriptionRuleNamingConvention |
UseWebSockets | UseWebSockets |
TokenCredential | Overloaded constructor of the transport |
CustomRetryPolicy | RetryPolicy |
TokenCredential
Previously when using CustomTokenCredential
or TokenCredential
it was required to pass a fully-qualified namespace (e.g.
) instead of a connection string (e.g. Endpoint=sb:/
). The dual purpose of the connection-string option has been removed. To use TokenCredential
pass the credential plus the fully-qualified namespace to the constructor of the transport.
3.2 NServiceBus.Transport.AzureServiceBus
var transportWithTokenCredentials = new AzureServiceBusTransport("[NAMESPACE].servicebus.windows.net", new DefaultAzureCredential());
endpointConfiguration.UseTransport(transportWithTokenCredentials);
3.x - 3.1 NServiceBus.Transport.AzureServiceBus
var transportWithTokenCredentials = new AzureServiceBusTransport("[NAMESPACE].servicebus.windows.net", new DefaultAzureCredential());
endpointConfiguration.UseTransport(transportWithTokenCredentials);
Accessing the native incoming message
The Azure.Messaging.ServiceBus client SDK introduces a set of new classes to represent messages. Previously there was only the Message
class to represent either an incoming message or an outgoing message. With the new client SDK the incoming message type is ServiceBusReceivedMessage
. If access to the native incoming message is required, make sure the correct type is used. See the native message customization documentation for further details.
Native message customization
IMessageHandlerContext
and IPipelineContext
no longer need to be passed to the CustomizeNativeMessage
method. See the native message customization documentation for further details.
Auto-lock renewal
The auto-lock renewal is now supported for an extended period of time and can be customized by specifying MaxAutoLockRenewalDuration
.
3.2 NServiceBus.Transport.AzureServiceBus
transport.MaxAutoLockRenewalDuration = TimeSpan.FromMinutes(10);
3.x - 3.1 NServiceBus.Transport.AzureServiceBus
transport.MaxAutoLockRenewalDuration = TimeSpan.FromMinutes(10);
Transaction timeout
The transport now allows transactions to take longer than the default TransactionManager.
. It is no longer required to override the maximum timeout.
Advanced/custom lock renewal
Previous versions of the transport required custom lock renewal logic to extend the renewal beyond five minutes, as outlined by the lock renewal sample. While this scenario still works as expected, it is encouraged to leverage the built-in lock renewal mechanism. Existing custom lock renewal implementations are required to change from
context.Extensions<ServiceBusReceiver>();
to
context.Extensions<ProcessMessageEventArgs>();