MSMQ Subscription Persistence

Project Hosting | Nuget: NServiceBus (Version: 5.x)
Storing subscriptions in MSMQ is not suitable when endpoints are scaled-out, because the subscription queue cannot be shared among multiple endpoints, especially if the endpoints are running on different machines.

To configure MSMQ as the subscription persistence:


When using MSMQ Subscription persistence, the default queue to store the subscription messages is NServiceBus.Subscriptions. It is important to override this queue name for each endpoint to avoid sharing the same subscription queue for different endpoints running on the same machine.

To specify a different subscriptions queue, add the following configuration as shown below:

    <section name="MsmqSubscriptionStorageConfig" 
             type="NServiceBus.Config.MsmqSubscriptionStorageConfig, NServiceBus.Core" />
  <MsmqSubscriptionStorageConfig Queue="YourQueue" />

Timeouts persistence

MsmqPersistence provides persistence only for storing event subscriptions. By default NServiceBus also requires a timeout persistence, which is used by Delayed Retries, Saga timeouts and for Delayed Delivery.

If none of these features are used then timeouts can be disabled:

If timeouts are disabled then features such as Delayed Retries and Saga timeouts cannot be used.

Another approach is to use a different persistence for features different than event subscriptions:

busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Sagas>();
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
busConfiguration.UsePersistence<MsmqPersistence, StorageType.Subscriptions>();

Last modified