MSMQ Subscription Persistence

Project Hosting
NuGet Package NServiceBus.Transport.Msmq (1-pre)
Target NServiceBus Version: 7.x
This page targets a pre-release version and is subject to change prior to the final release.

To configure MSMQ as the subscription persistence:


If the subscription storage is not specified, NServiceBus uses a queue called [Endpoint].Subscriptions. This is to avoid all endpoints deployed on the same server from having to share the same queue to store subscriptions. When a subscription queue is not specified and the default queue is being used, the following message will get logged:

The queue used to store subscriptions has not been configured, the default '.Subscriptions' will be used.

When using MSMQ Subscription Persistence on multiple endpoints running on the same machine, every endpoint must have a dedicated subscription storage queue.

Versions 5.x and Versions 6.x of NServiceBus used a default queue called NServiceBus.Subscriptions. An exception is thrown on startup if this queue is detected. Either specify the subscription queue explicitly or move the subscription messages to the new default queue to avoid message loss.

In order to specify a different queue, use the code API or specify a configuration section.

Via Code

Call the following code API passing the subscription queue to use:

var persistence = endpointConfiguration.UsePersistence<MsmqPersistence>();

Via App.config

Add the following configSections and subsequent config entry:

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

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:

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


Last modified