The distributor requires an additional queue where workers can send their status updates. This is the control queue. The default address is
The distributor stores metadata about the worker availability in the the queue with the suffix
When running with NServiceBus.Host.exe, the following profiles start the endpoint with the distributor functionality:
When self-hosting the endpoint, use this configuration:
// Running the Distributor and a Worker busConfiguration.AsMSMQMasterNode(); // or busConfiguration.RunMSMQDistributor(); // Running the Distributor only busConfiguration.RunMSMQDistributor(false);
Any NServiceBus endpoint can run as a worker node. To activate it, create a handler for the relevant messages and ensure that the
app. file contains routing information for the distributor.
If hosting the endpoint with
NServiceBus., to run as a worker, use this command line:
Configure the name of the master node server as shown in this
app. example. Note the
<configuration> <configSections> <!-- Other sections go here --> <section name="MasterNodeConfig" type="NServiceBus.Config.MasterNodeConfig, NServiceBus.Core" /> </configSections> <!-- Other config options go here --> <MasterNodeConfig Node="MachineWhereDistributorRuns"/> </configuration>
For more information, see
DistributorDataAddress in the Override distributor queues (advanced) section.
When self-hosting the endpoint, the following code will enlist the endpoint with a distributor.
Similar to self-hosting, when running NServiceBus prior to version 6, ensure the
app. of the worker contains the
MasterNodeConfig section to point to the hostname where the distributor process is running.
Enabling Outbox can result in increasing the enlisted capacity of a worker when errors occur. The distributor model is originally designed to work with distributed transactions (MSDTC). Consider using Sender Side Distribution instead. When enabling Outbox on a worker or master, explicitly set transaction mode to "Sends atomic with receive" as the Outbox sets the default transaction mode to "Receive Only".
var transport = endpointConfiguration.UseTransport<MsmqTransport>(); transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
Outbox is not required on the distributor; the forwarding of messages to workers is purely a transport operation and outbox will not participate in the forwarding logic.
The distributor process uses two queues for its runtime operation. The
DataInputQueue is the queue where the client processes send their messages. The
ControlInputQueue is the queue where the worker nodes send their control messages.
The NServiceBus default values for these settings can be overridden, as shown in the
UnicastBusConfig section below:
<UnicastBusConfig DistributorControlAddress="EndpointName.Distributor.Control@MachineWhereDistributorRuns" DistributorDataAddress="EndpointName@MachineWhereDistributorRuns"> <MessageEndpointMappings> <!-- regular entries --> </MessageEndpointMappings> </UnicastBusConfig>
Similar to standard NServiceBus routing, it is not desirable to have high priority messages to get stuck behind lower priority messages, so just as it is possible to have separate NServiceBus processes for different message types, it is also possible to set up different distributor process instances (with separate queues) for various message types.
In this case, name the queues after the message type. For example:
SubmitPurchaseOrder. becomes the name of the distributor data queue and the input queues of each of the workers.