The MSMQ Subscription storage can be used to enable publish/subscribe with MSMQ without the need for any additional persister.
Persistence at a glance
For a description of each feature, see the persistence at a glance legend.
Feature | |
---|---|
Supported storage types | Subscriptions only |
Transactions | Does not apply to subscriptions. |
Concurrency control | Does not apply to subscriptions. |
Scripted deployment | Not supported |
Installers | Subscription queues are created by installers. |
Configuration
To configure MSMQ as the subscription persistence:
busConfiguration.UsePersistence<MsmqPersistence>();
When using MSMQ subscription persistence, the default queue to store the subscription messages is NServiceBus.
. It is important to override this queue name for each endpoint to avoid sharing the same subscription queue for different endpoints running on the same machine.
To specify a different subscriptions queue, add the following configuration as shown below:
<configuration>
<configSections>
<section name="MsmqSubscriptionStorageConfig"
type="NServiceBus.Config.MsmqSubscriptionStorageConfig, NServiceBus.Core" />
</configSections>
<MsmqSubscriptionStorageConfig Queue="YourEndpointName.Subscriptions" />
</configuration>
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:
busConfiguration.DisableFeature<TimeoutManager>();
busConfiguration.UsePersistence<MsmqPersistence>();
Another approach is to use a different persistence storage types for features other than subscriptions like shown below:
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Sagas>();
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
busConfiguration.UsePersistence<MsmqPersistence, StorageType.Subscriptions>();