title | summary | tags | ||
---|---|---|---|---|
Disconnect Workers from a running Distributor |
How a worker can be disconnected from its distributor using PowerShell cmdlets |
|
NServiceBus 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
{{NOTE:
WorkerAddress
is the Worker queue name, eg Worker@localhostDistributorAddress
is the Distributor queue name eg MyDistributor@localhost, Note: you just pass the Distributor queue name, the PowerShell cmdlet will automatically appends ".distributor.control" to the end of the Distributor queue. }}
- Wait for Worker to drain all queued messages from its input queue.
- Shutdown the endpoint.
- A disconnect message is sent by the PowerShell to the Distributor control queue.
- When the Distributor processes it, the Worker with the address specified in the message is set with SessionID "disconnected".
- 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.