MSMQ Subscription Persistence usage

Component: MSMQ Persistence
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.

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

Prerequisites

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.

Configuration

endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
var persistence = endpointConfiguration.UsePersistence<MsmqPersistence, StorageType.Subscriptions>();
persistence.SubscriptionQueue("Samples.Msmq.Persistence.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