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
- AmazonSQS Transport Upgrade 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
- MSMQ Transport Upgrade Version 2 to 2.0.4
- RabbitMQ Transport Upgrade Version 7 to 8
- SQL Server Transport Upgrade Version 6 to 7
Persistence
- Cosmos DB Persistence Upgrade from 1 to 2
- NHibernate Persistence Upgrade Version 8 to 9
- RavenDB Persistence Upgrade from 7 to 8
- SQL Persistence Upgrade Version 6 to 7
Hosting
Other
This documentation contains information about breaking changes that may affect components like custom transports, persistence, and message serializers.
Serializers: Deserialization using ReadOnlyMemory of byte
Deserialization is updated to use ReadOnlyMemory
instead of Stream
. The Deserialize
method on IMessageSerializer
becomes:
object[] Deserialize(ReadOnlyMemory<byte> body, IList<Type> messageTypes = null);
Serializers that do not support ReadOnlyMemory
as deserialization input should avoid .
calls to prevent unnecessary memory allocations. Instead, it's recommended to implement a shim exposing read-only data as types supported by the serializer APIs or use existing implementations like ReadOnlyMemoryExtensions.
from the Microsoft.Toolkit.HighPerformance package.
Transports
Transports: Outgoing message TransportOperation API
The outgoing message body passed to the transport via TransportOperation
has a new constructor:
public TransportOperation(string messageId, DispatchProperties properties, ReadOnlyMemory<byte> body, Dictionary<string, string> headers)
Transports: Incoming message MessageContext API
A message body passed by the transport to the core using ReadOnlyMemory
instead of byte[]
. The MessageContext
becomes:
public MessageContext(string nativeMessageId, Dictionary<string, string> headers, ReadOnlyMemory<byte> body, TransportTransaction transportTransaction, ContextBag context)
For transports that use low allocation types, this allows passing message body without additional memory allocations. Secondly, this ensures that the message body is immutable and cannot be changed by the code executing in the pipeline.
Persisters
Persister Outbox API: TransportOperation based on ReadOnlyMemory<byte>
The outbox TransportOperation
is using ReadOnlyMemory
instead of byte[]
.