MSMQ Subscription Persistence usage

Component: MSMQ Persistence
NuGet Package NServiceBus.Transport.Msmq (1.x)
Target NServiceBus Version: 7.x

This sample shows basic usage of MSMQ as storage for subscriptions.


Ensure that MSMQ has been installed.

Code walk-through

The application publishes an empty message to itself, via the MSMQ transport, and writes to the console when the message is received.

Note that the default queue name, NServiceBus.Subscriptions, is overridden to avoid sharing the subscription storage queue with other endpoints on the same machine. The queue name is {EndpointName}.Subscriptions.


endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
var persistence = endpointConfiguration.UsePersistence<MsmqPersistence, StorageType.Subscriptions>();
MSMQ Persistence only supports subscription storage so another storage is needed for Timeouts since MSMQ doesn't have native timeout support.

Related Articles

Last modified