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
In RavenDB 3.5, the client implementation of distributed transactions contains a bug that could cause an endpoint to lose data under rare conditions. If RavenDB is configured to enlist in distributed transactions with RavenDB 3.5, read DTC not supported for RavenDB Persistence.
Using RavenDB version 5 and higher in a cluster configuration with multiple nodes is only supported from version 7 or higher of the NServiceBus.RavenDB persistence package. For more information, read cluster configuration with multiple nodes.
As part of this update, NServiceBus Version 6 will be required.
Migrate saga data if using AllowStaleSagaReads
Due to changes in how NServiceBus Version 6 handles saga correlation properties, solutions that previously used the AllowStaleSagaReads()
option in RavenDB Persistence will not work properly and need to be migrated during upgrade.
Failure to migrate saga data when using the AllowStaleSagaReads()
option will result in NServiceBus being unable to locate saga data, which will cause it to create duplicate saga data erroneously.
To enable efficient saga loading in one server round-trip, RavenDB persistence will use a pointer document to load the saga data document by the correlation property in an atomic and consistent manner, without using RavenDB indexes that are (by design) not updated atomically with the document store.
When using the AllowStaleSagaReads()
option in previous versions, which was sometimes used to support correlating saga data on multiple properties, pointer documents were not used and RavenDB indexes (which might be stale) were used instead.
Starting in NServiceBus Version 6, only one correlation id is supported, and the AllowStaleSagaReads()
option is deprecated. However, saga data stored using this option in previous versions will not have the unique identity pointer document, and will not be able to load. The result is that NServiceBus will not be able to find the saga data document. If the message handler is implemented in the saga as IHandleMessages
, then the message will be incorrectly discarded as belonging to a saga that has already completed. If the message handler is implemented in the saga as IAmStartedByMessages
. then a new saga data will (incorrectly) be created, leading to duplicate saga data documents and incorrect business execution.
When upgrading, if the AllowStaleSagaReads
option is in use, contact support@particular.net for assistance in identifying the scope of the problem and migration of data.
Namespace changes
Namespaces for public types have been consolidated to make customizations more discoverable. The primary namespaces are NServiceBus
for customization options that need to be discoverable, and NServiceBus.
for advanced APIs. A single using NServiceBus
directive should be sufficient to find all necessary options.
As part of this move, the following classes were moved to different namespaces:
NServiceBus.
to thePersistence. RavenDBPersistence NServiceBus
namespace.NServiceBus.
to theRavenDB. Outbox. RavenDBOutboxExtensions NServiceBus
namespace.NServiceBus.
to theRavenDB. ConnectionParameters NServiceBus.
namespace.Persistence. RavenDB
Use of RavenDB Async API
NServiceBus now uses the asynchronous RavenDB API for all operations. If sharing the session between NServiceBus and handler code is required, then handler code will need to be adjusted to utilize the asynchronous RavenDB API as well.
Previously, the API exposed an IDocumentSession
, but now exposes IAsyncDocumentSession
instead, which contains the same operations using a Task-based API.
Configuring a shared session
Configuring a shared raven session now requires a Func
instead of a Func
.
Func<IAsyncDocumentSession> sessionFactory = () => someAsyncSession;
var persistence = endpointConfiguration.UsePersistence<RavenDBPersistence>();
persistence.UseSharedAsyncSession(sessionFactory);
ISessionProvider is obsolete
In Version 3 of NServiceBus.RavenDB, an ISessionProvider
was available for dependency injection. The new method of accessing the raven session is the SynchronizedStorageSession
.
public class HandlerWithRavenSession :
IHandleMessages<MyMessage>
{
public Task Handle(MyMessage message, IMessageHandlerContext context)
{
var ravenSession = context.SynchronizedStorageSession
.RavenSession();
return SomeLibrary.SomeAsyncMethod(message, ravenSession);
}
}
Session is available regardless of features enabled
In Version 3, the RavenStorageSession
was only registered if at least one out of Outbox and Sagas were enabled. There are possible use cases for using the NServiceBus wrapped RavenDB session, so the prerequisites have been removed.