Rhino-esb handling exceptions in ConsumerOf

25 views
Skip to first unread message

DaeMoohn

unread,
Dec 7, 2011, 5:52:47 AM12/7/11
to Rhino Tools Dev
Hi,

I set up consumers for my messages. In some of these consumers
exception may be thrown (like being unable to insert a row in a
database etc.).

Is there a best practice in this scenario and how can it be
implemented using Rhino-esb? Should I move the messages to a special
queue where they would be manually picked up and reprocessed? (or a
manually triggered process would exist that would do that)

Jason Meckley

unread,
Dec 7, 2011, 8:31:26 AM12/7/11
to rhino-t...@googlegroups.com
by default the bus will attempt to consume a message 3 times (this can be overrriden). after that the message is moved to the error queue. With MSMQ you can easily move the message back into the the main queue for processing once the bug is resolved and the message can be processed. With RQ I haven't found a good way to get the message out of the error queue.

if you want to add additional "generic" behavior to the exception handling workflow then implement IMessageModule and hook into the appropriate messaging events (arrived, completed, error, etc). Note: if you will be sending another message from the message module and an exception is thrown, you will need to explicitly wrap the action in a new transaction scope. otherwise the message will not be sent because the parent transaction is rolled back.

using(var tx = new TransactionScope(Scope.RequiresNew))
{
   var message = new HandlingExceptionMessage{Exception = exception};
   bus.Send(message);
   tx.Complete();
}

DaeMoohn

unread,
Dec 7, 2011, 8:49:41 AM12/7/11
to Rhino Tools Dev
Thank you!
Reply all
Reply to author
Forward
0 new messages