MSMQ Transport Upgrade Version 1 to 2

Component: MSMQ Transport
This page targets a pre-release version. Pre-releases are subject to change and samples are not guaranteed to be fully functional.

Configuring the MSMQ transport

To use the MSMQ transport for NServiceBus, create a new instance of MsmqTransport and pass it to EndpointConfiguration.UseTransport.

Instead of

var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.ConnectionString(connectionString);

Use:

var transport = new MsmqTransport();
endpointConfiguration.UseTransport(transport);

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:

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);

When upgrading from version 1 to 2, any currently 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 optionVersion 2 configuration option
ApplyLabelToMessagesApplyCustomLabelToOutgoingMessages
TransactionScopeOptionsConfigureTransactionScope
UseDeadLetterQueueForMessagesWithTimeToBeReceivedUseDeadLetterQueueForMessagesWithTimeToBeReceived
DisableInstallerCreateQueues
DisableDeadLetterQueueingUseDeadLetterQueue
DisableConnectionCachingForSendsUseConnectionCache
UseNonTransactionalQueuesUseTransactionalQueues
EnableJournalingUseJournalQueue
TimeToReachQueueTimeToReachQueue
DisableNativeTimeToBeReceivedInTransactionsUseNonNativeTimeToBeReceivedInTransactions
IgnoreIncomingTimeToBeReceivedHeadersIgnoreIncomingTimeToBeReceivedHeaders

Related Articles

  • MSMQ Transport
    MSMQ is a solid durable communications technology but does not dynamically detect network interfaces.
  • Upgrade Version 7 to 8
    Instructions on how to upgrade NServiceBus from version 7 to version 8.

Last modified