What happens when calling endpoint.Stop() while the endpoint is processing a message?

201 views
Skip to first unread message

Ben Way

unread,
Apr 12, 2017, 1:20:14 PM4/12/17
to Particular Software
We are replacing a home grown bus with NServiceBus and I am converting our current endpoints into NServiceBus endpoints.  

In our current system when an endpoint gets a stop request it will:
  1. Stop receiving new messages from the queue.
  2. Finish handling messages currently in the pipeline.
  3. Stop/Shutdown
What does an NServiceBus endpoint do when Shutdown is called? I can't find documentation that outlines the sequence of events that an endpoint will take when stop is requested, is there any?  Will a currently processing message complete normally or will it be aborted or cancelled?

Thanks,
Ben

Daniel Marbach

unread,
Apr 12, 2017, 2:21:22 PM4/12/17
to Particular Software
Hi Ben,

The answer is: It depends. It depends on the transport and the transaction mode. In general, it works how you outlined it:

It will stop receiving messages from the queue
Finish handling messages currently in the pipeline (some transports do that indefinitely like RabbitMQ or have a timeout of 30 seconds i.ex. MSMQ)
Stop/shutdown

If you have a transactional transport and a transactional mode selected messages after the timeout (if there is any) will be rolled back. If you have no transaction the messages in-flight will already be marked as handled and all bets are off.

Hope that answers your question

Daniel
Reply all
Reply to author
Forward
0 new messages