MSMQ Subscription Persistence usage

Component: MSMQ Persistence
NuGet Package NServiceBus (6.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 event to itself and writes to the console when the event is received.


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

//Default queue name, `NServiceBus.Subscriptions`, is overridden to avoid sharing the subscription storage queue with other endpoints on the same machine. 

endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
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