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:


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