The Distributor starts sending messages to a Worker once it is aware of it. A Worker registers itself with a Distributor by sending a message containing a
SessionID that identifies the current running Worker and the number of messages it can handle concurrently.
If the Worker is configured using the NServiceBus.Distributor.MSMQ NuGet, there is a PowerShell cmdlet that can be used to disconnect a Worker from a Distributor. The steps are the following:
- Load the NServiceBus PowerShell CmdLet and execute
Remove-NServiceBusMSMQWorker WorkerAddress DistributorAddress TransactionalDistributorQueue
WorkerAddressis the Worker queue name, eg
DistributorAddressis the Distributor queue name eg
MyDistributor@localhost, Note: Pass the Distributor queue name, the PowerShell cmdlet will automatically appends ".distributor.control" to the end of the Distributor queue.
TransactionalDistributorQueueis the Distributor queue transactional or not ?
- Wait for Worker to drain all queued messages from its input queue.
- Shutdown the endpoint.
- A disconnect message is sent by the PowerShell cmdlet to the Distributor control queue.
- When the Distributor processes it, the Worker with the address specified in the message is set with SessionID
- Ready messages sent back by the Worker to the Distributor never match the session, so they are skipped and that way the Worker won't receive any more messages from the Distributor.