This is part of the NServiceBus Upgrade Guide from Version 5 to 6, which also includes the following individual upgrade guides for specific components:
Feature Details
- Assembly Scanning Changes in NServiceBus Version 6
- No Async Suffix
- Dependency Injection Changes in NServiceBus Version 6
- Deprecated TransportMessage in NServiceBus Version 6
- Endpoint API changes in NServiceBus Version 6
- Extension Seam Changes in NServiceBus Version 6
- Migrate handlers and sagas to Version 6
- Header API changes in NServiceBus Version 6
- Messaging Changes in NServiceBus Version 6
- Moving away from IBus in Version 6
- Recoverability Changes in Version 6
- Serialization Changes in NServiceBus Version 6
- Subscription Changes in NServiceBus Version 6
- Transaction Configuration Changes in NServiceBus Version 6
Transports
- Azure Service Bus Transport (Legacy) Upgrade Version 6 to 7
- RabbitMQ Transport Upgrade Version 3 to 4
- SQL Server Transport Upgrade Version 2 to 3
- SQL Server Transport Upgrade - Supporting Unicode in Headers
Persistence
- Upgrade from NServiceBus Azure Version 6
- NHibernate Persistence Upgrade Version 6 to 7
- NHibernate Persistence - Resolving incorrect timeout table indexes
- RavenDB Persistence Upgrade from 3 to 4
Hosting
Other
- Moving to the DataBus AzureBlobStorage Package
- Azure Cloud Services Host Upgrade Version 6 to 7
- NServiceBus.Azure package deprecated
- Gateway Upgrade Version 1 to 2
- NServiceBus Testing Upgrade Version 5 to 6
- Callback Changes in NServiceBus Version 6
- Migrating the distributor to use sender-side distribution
- Tool and Helper Changes in NServiceBus Version 6
Storage
ISubscriptionStorage
has been split into two interfaces, ISubscriptionStorage
and IInitializableSubscriptionStorage
, to properly separate subscription storage concerns. ISubscriptionStorage
must be implemented to have a fully functional subscription infrastructure. IInitializableSubscriptionStorage
is necessary only when the subscription storage needs to be initialized.
ISubscriptionStorage
implements the concern of storage, retrieval, and removal for subscriptions, which is executed inside the context of a pipeline. Furthermore, ISubscriptionStorage
introduced a new parameter: SubscriptionStorageOptions
. This parameter allows access to the pipeline context which enables subscription storages to manipulate everything that exists in the context during message pipeline execution.
Automatically subscribing plain messages
The option to automatically subscribe to plain messages was removed, as message subscription should be based on events. Although not recommended, this can be overridden by manually subscribing to other message types.
SubscriptionEventArgs has been deprecated
NServiceBus version 5 introduced an undocumented way to get the list of subscribers when publishing a message on the transports using persistence based pub/sub. This is no longer available; contact support should this information be required in version 6.
Automatic subscription
The configuration option DoNotRequireExplicitRouting()
is obsolete since transports with support for centralized pub/sub will always auto subscribe all events without requiring explicit routing. Transports with message-driven pub/sub (like MSMQ, SQL Server, and Azure Storage Queues) will not subscribe properly if there is no routing specified. Any code that uses this option can now be safely removed.
Automatic subscription happens during the startup phase of the bus. Previous versions of NServiceBus tried to subscribe multiple times on a background thread until the subscription either succeeded or failed. When the subscription failed, an error entry was written to the log file. NServiceBus version 6 changes that behavior for transports with message-driven pub/sub. Subscription is tried asynchronously on the startup thread. In the case when a subscriber starts and the publisher has never created its queues, the subscriber endpoint will not start and the caller will receive a QueueNotFoundException
indicating what went wrong.
MSMQ subscription authorization
MSMQ subscription authorization is now done by the SubscriptionAuthorizer
delegate at configuration time and not by the IAuthorizeSubscriptions
interface.
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.SubscriptionAuthorizer(context =>
{
var headers = context.MessageHeaders;
var subscriptionMessageType = headers[Headers.SubscriptionMessageType];
var messageIntent = headers[Headers.MessageIntent];
var messageIntentEnum = (MessageIntentEnum)Enum.Parse(typeof(MessageIntentEnum), messageIntent, true);
// messageIntentEnum will be either MessageIntentEnum.Unsubscribe or MessageIntentEnum.Subscribe
var endpointName = headers[Headers.SubscriberEndpoint]
.ToLowerInvariant();
// true to allow false to decline
return true;
});