You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rschetti <rs...@verizon.net> on 2011/08/17 15:24:06 UTC
Mixing UnitOfWork/Synchronization and onException() Handling
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: http://camel.465427.n5.nabble.com/Mixing-UnitOfWork-Synchronization-and-onException-Handling-tp4708180p4708180.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mixing UnitOfWork/Synchronization and onException() Handling
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
This is my reply from the Fuse forum
http://fusesource.com/forums/thread.jspa?threadID=3256&tstart=0
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
http://activemq.apache.org/message-redelivery-and-dlq-handling.html
Then you dont need to use the onException at all.
On Wed, Aug 17, 2011 at 3:29 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Posted to this forum as well
> http://fusesource.com/forums/thread.jspa?threadID=3256&tstart=0
>
> Where this is already being discussed.
>
> On Wed, Aug 17, 2011 at 3:24 PM, rschetti <rs...@verizon.net> 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: http://camel.465427.n5.nabble.com/Mixing-UnitOfWork-Synchronization-and-onException-Handling-tp4708180p4708180.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Mixing UnitOfWork/Synchronization and onException() Handling
Posted by Claus Ibsen <cl...@gmail.com>.
Frankly its not a cool answer. Its just that people should have a bit
more patience when they post for help in one community. And not cross
posts in many communities, as it spread the conversation. And for
people who take the time to help at X, would have to do the same at
place Y etc.
I personally would wait 1-2 days and if no activity at X, then I would
move on and ask at Y (but mention that I have also asked at X) etc.
Anyway the ball is rolling here at Apache @user as well. So dive in if
you can help.
On Wed, Aug 17, 2011 at 3:37 PM, bvahdat <ba...@swissonline.ch> wrote:
> Claus,
> That was the coolest answer I've ever seen by you.
> It seems that the "Big Brother" is watching/tracking you everywhere.
>
> Regards, Babak
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Mixing-UnitOfWork-Synchronization-and-onException-Handling-tp4708180p4708244.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Mixing UnitOfWork/Synchronization and onException() Handling
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Aug 17, 2011 at 3:37 PM, bvahdat <ba...@swissonline.ch> wrote:
> Claus,
> That was the coolest answer I've ever seen by you.
> It seems that the "Big Brother" is watching/tracking you everywhere.
>
I'm a borg ... ehh bot, i'm not a human ;)
> Regards, Babak
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Mixing-UnitOfWork-Synchronization-and-onException-Handling-tp4708180p4708244.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Mixing UnitOfWork/Synchronization and onException() Handling
Posted by bvahdat <ba...@swissonline.ch>.
Claus,
That was the coolest answer I've ever seen by you.
It seems that the "Big Brother" is watching/tracking you everywhere.
Regards, Babak
--
View this message in context: http://camel.465427.n5.nabble.com/Mixing-UnitOfWork-Synchronization-and-onException-Handling-tp4708180p4708244.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mixing UnitOfWork/Synchronization and onException() Handling
Posted by Claus Ibsen <cl...@gmail.com>.
Posted to this forum as well
http://fusesource.com/forums/thread.jspa?threadID=3256&tstart=0
Where this is already being discussed.
On Wed, Aug 17, 2011 at 3:24 PM, rschetti <rs...@verizon.net> 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: http://camel.465427.n5.nabble.com/Mixing-UnitOfWork-Synchronization-and-onException-Handling-tp4708180p4708180.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/