views:

335

answers:

1

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?

+1  A: 

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.blogspot.com/2010/03/errorhandling-in-message-oriented-world.html

Hope this helps!

Andreas
Thank you, Andreas. I have already red your article before asking this question).Can you tell me if it is possible to have many message buses hosted in one process? Is it ok or nservicebus does not support this? Or may be there will be severe perfomance penalties with many buses working in one process?
Tabernakli
In the default configuration mode, you can only have one bus per app-domain. The thing is that you'd likely want to have your error queue on a separate machine, and have all other processes moving their errors there. Then you'd have a single process/bus feeding off of that error queue doing your own custom logic.
Udi Dahan