camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Mixing UnitOfWork/Synchronization and onException() Handling
Date Wed, 17 Aug 2011 16:23:30 GMT

This is my reply from the Fuse forum

If you use JMS then the JMS broker has built in support for error
queues (dead letter channel). So its in fact better to use that,
instead of having Camel sending the message back to the error queue.
Then all that is handled within the broker.

See chapter 9 in the Camel in Action book.

The Apache ActiveMQ web site have a few details as well

Then you dont need to use the onException at all.

On Wed, Aug 17, 2011 at 3:29 PM, Claus Ibsen <> wrote:
> Posted to this forum as well
> Where this is already being discussed.
> On Wed, Aug 17, 2011 at 3:24 PM, rschetti <> wrote:
>> Experienced Camel Users,
>> I am a relatively new Camel user. I have successfully setup the "happy case"
>> where Camel (using transactions) is routing messages through multiple JMS
>> queues. Now it's time to add some error handling...
>> I use a UnitOfWork to manage updates to the file system (almost exactly as
>> described in "Camel in Action" chapter 9). When the Camel route succeeds, I
>> create a file. When the route fails, the file is deleted. The UnitOfWork
>> operates as expected when exceptions are thrown from my Processors and
>> caught by Camel.
>> My problems occur when I add onException() to my DSL to catch and handle any
>> exceptions manually. On an exception, I would like to redirect the errant
>> message to an "error queue"
>> onException(Exception.class).handled(true).to("myErrorQueue").end()
>> By stating handled(true), Camel believes that the route was successful, and
>> the onComplete() method is called on the elements of the UnitOfWork. In my
>> case, I don't want that to happen, I want the UnitOfWork to call
>> onFailure().
>> I tried using handled(false). In this case, the onFailure() method was
>> applied to the elements of the UnitOfWork, but Camel did not route the
>> errant message to "myErrorQueue". Instead, Camel retried processing the
>> message 6 times (the default # of retries) and then moved the message to the
>> DeadLetterQueue.
>> So I'm stuck. How can I combine onException() to handle the errors, but
>> still have the UnitOfWork treat the exceptions as "failures"?
>> Any assistance would be greatly appreciated.
>> --
>> View this message in context:
>> Sent from the Camel - Users mailing list archive at
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email:
> Web:
> Twitter: davsclaus, fusenews
> Blog:
> Author of Camel in Action:

Claus Ibsen
Twitter: davsclaus, fusenews
Author of Camel in Action:

View raw message