camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rschetti <>
Subject Mixing UnitOfWork/Synchronization and onException() Handling
Date Wed, 17 Aug 2011 13:24:06 GMT
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"


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

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

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

View raw message