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
EnableMigrationMode has moved
The previous location of the EnableMigrationMode
has been deprecated and the persistenceConfiguration.
should be used instead.
Changes to transactions
Move to the new transactions API
A new Transactions API has been introduced to determine the PartitionKey
and ContainerInformation
. It is recommended to move from using a behavior-based approach to using this new API instead.
Identifying the PartitionKey
The most simple way to extract the PartitionKey
from the headers is by using the following method:
var transactionInformation = persistence.TransactionInformation();
transactionInformation.ExtractPartitionKeyFromHeader("PartitionKeyHeader");
The most simple way to extract the PartitionKey
from the message is by using the following method:
var transactionInformation = persistence.TransactionInformation();
transactionInformation.ExtractPartitionKeyFromMessage<MyMessage>(message => new PartitionKey(message.ItemId));
For more ways to set the PartitionKey
see the Transactions API documentation.
Identifying the ContainerInformation
The most simple way to extract the ContainerInformation
from the headers is by using the following method:
var transactionInformation = persistence.TransactionInformation();
transactionInformation.ExtractContainerInformationFromHeaders(headers => new ContainerInformation(headers["ContainerNameHeader"], new PartitionKeyPath("/partitionKeyPath")));
The most simple way to extract the ContainerInformation
from the message is by using the following method:
var transactionInformation = persistence.TransactionInformation();
transactionInformation.ExtractContainerInformationFromMessage<MyMessage>(message => new ContainerInformation(message.ItemId.ToString(), new PartitionKeyPath("/partitionKey")));
For more ways to set the ContainerInformation
see the Transactions API documentation.
LogicalOutboxBehavior
has been deprecated
The LogicalOutboxBehavior
has been marked as deprecated and will be internal only starting with version 3.0.
To continue to use Behaviors to determine the PartitionKey or ContainerInformation registration should be updated to use the string literal of the behavior class name:
public class RegisterMyBehavior : RegisterStep
{
public RegisterMyBehavior() :
base(stepId: nameof(PartitionKeyIncomingLogicalMessageContextBehavior),
behavior: typeof(PartitionKeyIncomingLogicalMessageContextBehavior),
description: "Determines the PartitionKey from the logical message",
factoryMethod: b => new PartitionKeyIncomingLogicalMessageContextBehavior())
{
- InsertBeforeIfExists(nameof(LogicalOutboxBehavior));
+ InsertBeforeIfExists("LogicalOutboxBehavior");
}
}
It is recommended to move from using a behavior-based approach to using the new Transactions API instead.