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
Configuring the MSMQ transport
To use the MSMQ transport for NServiceBus, create a new instance of MsmqTransport
and pass it to EndpointConfiguration.
.
Instead of:
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.ConnectionString(connectionString);
Use:
var transport = new MsmqTransport();
endpointConfiguration.UseTransport(transport);
The existing API surface with UseTransport
is supported via a shim API to ease migration. However, it is recommended to switch to the new transport configuration API to prepare for future upgrades of NServiceBus.
Delayed delivery
Version 2 supports delayed delivery of messages by persisting them in a delayed message store. There is a built-in SQL Server-based store and an extension point for custom stores.
In version 2, explicit configuration is required to enable delayed message delivery. For example:
2.x NServiceBus.Transport.Msmq
var messageStore = new SqlServerDelayedMessageStore(
connectionString: "database=(local); initial catalog=my_catalog; integrated security=true",
schema: "my_schema", //optional, defaults to dbo
tableName: "my_delayed_messages"); //optional, defaults to endpoint name with '.delayed' suffix
var transport = new MsmqTransport
{
DelayedDelivery = new DelayedDeliverySettings(messageStore)
{
NumberOfRetries = 7,
MaximumRecoveryFailuresPerSecond = 2,
TimeToTriggerStoreCircuitBreaker = TimeSpan.FromSeconds(20),
TimeToTriggerDispatchCircuitBreaker = TimeSpan.FromSeconds(15),
TimeToTriggerFetchCircuitBreaker = TimeSpan.FromSeconds(45)
}
};
endpointConfiguration.UseTransport(transport);
1.2 NServiceBus.Transport.Msmq
var messageStore = new SqlServerDelayedMessageStore(
connectionString: "database=(local); initial catalog=my_catalog; integrated security=true",
schema: "my_schema", //optional, defaults to dbo
tableName: "my_delayed_messages"); //optional, defaults to endpoint name with '.delayed' suffix
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
var delayedDeliverySettings = transport.NativeDelayedDelivery(messageStore);
delayedDeliverySettings.NumberOfRetries = 7;
delayedDeliverySettings.MaximumRecoveryFailuresPerSecond = 2;
delayedDeliverySettings.TimeToTriggerStoreCircuitBreaker = TimeSpan.FromSeconds(20);
delayedDeliverySettings.TimeToTriggerDispatchCircuitBreaker = TimeSpan.FromSeconds(15);
delayedDeliverySettings.TimeToTriggerFetchCircuitBreaker = TimeSpan.FromSeconds(45);
endpointConfiguration.DisableFeature<TimeoutManager>();
When upgrading from version 1 to 2, all the existing delayed messages must be migrated using the timeout migration tool.
Configuration options
The MSMQ transport configuration options have been moved to the MsmqTransport
class. See the following table for further information:
Version 1 configuration option | Version 2 configuration option |
---|---|
ApplyLabelToMessages | ApplyCustomLabelToOutgoingMessages |
TransactionScopeOptions | ConfigureTransactionScope |
UseDeadLetterQueueForMessagesWithTimeToBeReceived | UseDeadLetterQueueForMessagesWithTimeToBeReceived |
DisableInstaller | CreateQueues |
DisableDeadLetterQueueing | UseDeadLetterQueue |
DisableConnectionCachingForSends | UseConnectionCache |
UseNonTransactionalQueues | UseTransactionalQueues |
EnableJournaling | UseJournalQueue |
TimeToReachQueue | TimeToReachQueue |
DisableNativeTimeToBeReceivedInTransactions | UseNonNativeTimeToBeReceivedInTransactions |
IgnoreIncomingTimeToBeReceivedHeaders | IgnoreIncomingTimeToBeReceivedHeaders |