Data distribution

Component: NServiceBus
NuGet Package NServiceBus (5.x)
Asynchronous messaging is not an optimal solution for data distribution scenarios. It is usually better to use a dedicated data distribution technology for that purpose, such as a distributed cache or distributed configuration service.

The NServiceBus Publish-Subscribe implementation is designed to deliver events to a single physical instance of a logical subscriber. In order to distribute data, it may be necessary to deliver events to all physical instances of a logical subscriber. While it is usually better to use a dedicated data distribution technology for that purpose, such as a distributed caching solution, NServiceBus can also be used to distribute data.

5.2 NServiceBus
var scaleOutSettings = busConfiguration.ScaleOut();
scaleOutSettings.UniqueQueuePerEndpointInstance();

The code above configures NServiceBus to use a unique input queue for each physical endpoint instance. Each queue name is the endpoint name suffixed by the Azure role instance ID. Since each subscriber has its own unique input queue, the publisher treats them as if they are separate logical subscribers and delivers events to all of them.

Alternatively, a custom queue name suffix can be specified (instead of using the Azure role instance ID):

5.2 NServiceBus
var scaleOutSettings = busConfiguration.ScaleOut();
scaleOutSettings.UniqueQueuePerEndpointInstance("-MyCustomSuffix");

Last modified