Retry on Processing Failure

Mar 27, 2009 at 2:53 PM
Nathan, this project looks great.  Although I am always amazed by Udi, I started to glaze over when reading up on nServiceBus and was very happy to run across SSB.

I've looked through the code and haven't been able to answer my questions, so I'll ask.  If a subscriber throws while processing a message, does the message get retried?  If not, would you rely on the transport (e.g. MSMQ) for that?  Or would this be handled by some other mechanism that gets plugged in that maybe handles a distributor / worker paradigm.

Basically, say I submit and order and it needs some long-term processing but the message handler ends up bailing for some reason.  How would you handle that?  I would appreciate any insight you have on this.

Thank you,
Jason
Coordinator
Mar 27, 2009 at 7:17 PM
The endpoint can be configured with some number of "retry" attempts (definitely on the trunk, not 100% sure if this code is in the release download). This is generally done in the xml config file for the endpoint, but is a property on the endpoint metadata (myEndpoint.Metadata). The bus will attempt to re-send a failed message x number of times. If all retries are exhausted, the message is send to the Poison Queue if you have one defined. This is also configured in the xml configuration and part of the endpoint Metadata. Once a message ends up in the poison queue, SSB washes its hands of the message - your application logic will need some way of dealing with these messages. At the same time, an event is raised on the Message Bus which you can listen and react to - something like MessageProcessingError, and if you have a Monitor Service configured to watch endpoint health, a message is automatically sent to the monitor service, which can take some (custom) action if you so desire. Does that answer your question? Let me know if you have any trouble configuring this scenario and I can be more specific. The best place to look is the TestApp.config file in the unit tests - that is a complete config file showing all options.