NServiceBus Publish/Subscribe mechanism always delivers events to a single instance of each logical subscriber. Sometimes, however, there is a reason for delivering each event to all instances of the subscriber in order to distribute data. While it is usually better to use a dedicated data distribution technology for that purpose (e.g. a distributed caching solution), NServiceBus can also be used in data-distribution mode.
var scaleOutSettings = busConfiguration.ScaleOut(); scaleOutSettings.UniqueQueuePerEndpointInstance();
The code above instructs NServiceBus to use a unique input queue for each endpoint instance. The actual queue name is derived from the endpoint name and the Azure role instance ID. When instances of such endpoint subscribe for an event, each instance subscribes with its own unique input queue so the publisher treats each subscription individually and, as a result, broadcasts events to all subscribed instances.
In case there is a need to provide a custom queue names suffix (instead of using the role instance ID), following API can be used instead:
var scaleOutSettings = busConfiguration.ScaleOut(); scaleOutSettings.UniqueQueuePerEndpointInstance("-MyCustomSuffix");