Question

We are planning to use NServiceBus in our application for dispatching messages. In our case each message has timeToLive property, defining period of time, in which this message should be processed.

For the case if message handling was unsuccessful in first attempt, our plan is to move it to specific retry storage (retry queue) and than retry message (with some timeouts between retries) while it is successfully handled or timeToLive is expired.

In case if timeToLive is expired, we plan to log message content and discard message.

Actually, this retry behaviour is mostly determined by protocol, which we are implementing.

Is there any ways to achieve such a behaviour with NServiceBus? I see, that unsuccessful messages goes to specific error queue. Is it possible to create a separate bus, pointing to error queue?

Was it helpful?

Solution

I would suggest that you have a separate process that monitors the error queue perform retries according to the logic you describes. Take a look at the ReturnToSourceQueue tool that comes with nservicebus for inspiration:

http://nservicebus.svn.sourceforge.net/viewvc/nservicebus/trunk/src/tools/management/Errors/ReturnToSourceQueue/NServiceBus.Tools.Management.Errors.ReturnToSourceQueue/Class1.cs?view=markup

I have a blog post on how to handle failures that might give you some ideas as well: http://andreasohlund.net/2010/03/15/errorhandling-in-a-message-oriented-world/

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top