MSMQ Subscription Persistence

NuGet Package: NServiceBus (6.x)
Standard support for version 6.x of NServiceBus has expired. For more information see our Support Policy.

The MSMQ Subscription storage can be used to enable publish/subscribe with MSMQ without the need for any additional persister.

This can only be used to store subscriptions. To use sagas, timeouts, deferred messages, or the Outbox, a different persister is required.

Persistence at a glance

For a description of each feature, see the persistence at a glance legend.

Supported storage typesSubscriptions only
TransactionsDoes not apply to subscriptions.
Concurrency controlDoes not apply to subscriptions.
Scripted deploymentNot supported
InstallersSubscription queues are created by installers.


MSMQ Persistence does not support scaled-out publishers. This is because the MSMQ storage is local to the machine, and a subscription message will only be delivered to one endpoint instance of a given logical endpoint, and only that instance will be able to update its information, while other instances remain unaware of the new subscriber.
The subscription queue can contain duplicate entries. This is by design and does not result in events being published multiple times. Subscription entries are added for each subscription request received. After a publisher restarts, the subscription queue state will be rewritten and deduplicated.

To configure MSMQ as the subscription persistence:


By default NServiceBus uses a queue called NServiceBus.Subscriptions. If not specified otherwise, all endpoints will share that queue to store subscriptions. The following warning message will get logged:

NServiceBus.Features.MsmqSubscriptionPersistence Could not find configuration section for Msmq Subscription Storage and no name was specified for this endpoint. Going to default the subscription queue

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

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, timeouts can be disabled:

If timeouts are disabled, features such as delayed retries and saga timeouts cannot be used.

Another approach is to use a different persistence storage types for features other than subscriptions like shown below:

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


Last modified