You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by marnold <ma...@gmail.com> on 2012/08/07 21:37:17 UTC

TransactedErrorHandler requeue JMS message to DLQ

Camel Users,

I'm using Camel 2.9.0.  I have the following route:

        <route id="test">
        	<from uri="jms:queue:queue.test" />
        	<to uri="jms:queue:queue.someQueue"/>
        	<process ref="testProcess"/>
        	<to uri="jms:queue:queue.someOtherQueue"/>
        </route>

Where testProcess always throws an exception. For testing purposes!

My goal is to achieve the following: (i) if <process> fails, the enqueue to
'queue.someQueue' should always be rolled-back; (ii)  if <process> fails,
Camel should retry the route a configurable maximum number of times; (iii)
If the route fails the maximum number of times, the initial message dequeued
from 'queue.test' should be enqueued onto a dead-letter queue so that the
next message on 'queue.test' can be processed.

My understanding is that this should be a 'transacted' route, and that I
should use a TransactedErrorHandler.  I have read the documentation here:
http://camel.apache.org/transactionerrorhandler.html

But I'm afraid I cannot understand this rather intimidating sentence: "When
the ValidationException is thrown from the validate order bean it is
intercepted by the TransactionErrorHandler and it let the
onException(ValidationException.class handle it so the Exchange is routed to
this route and since we use handled(true) then the original exception is
lowered (= cleared) and we transform the message into a fixed response that
are returned to jetty endpoint that returns it to the original caller."

If anyone could offer an explanation, help or advice, or point out an
example that acheives something similar to my desired behaviour, I would be
very appreciative. 

We are using ActiveMQ as our JMS implementation, but would rather keep this
JMS implementation non-specific.

Thanks.








--
View this message in context: http://camel.465427.n5.nabble.com/TransactedErrorHandler-requeue-JMS-message-to-DLQ-tp5716945.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: TransactedErrorHandler requeue JMS message to DLQ

Posted by Willem jiang <wi...@gmail.com>.
First I want to ask work MessageExchangePattern are you using.
I don't think you can do it with InOut MEP, as it more complicated then the InOnly.

The TransactionHandler will rollback the transaction when the exception is thrown, 
as you testProcess is behind the someQueue endpoint, if you need to make sure the transaction token will not be change. You can find some explanation here[1]

[1]http://camel.apache.org/transactional-client.html

-- 
Willem Jiang



On Wednesday, August 8, 2012 at 3:37 AM, marnold wrote:

> Camel Users,
> 
> I'm using Camel 2.9.0. I have the following route:
> 
> <route id="test">
> <from uri="jms:queue:queue.test" />
> <to uri="jms:queue:queue.someQueue"/>
> <process ref="testProcess"/>
> <to uri="jms:queue:queue.someOtherQueue"/>
> </route>
> 
> Where testProcess always throws an exception. For testing purposes!
> 
> My goal is to achieve the following: (i) if <process> fails, the enqueue to
> 'queue.someQueue' should always be rolled-back; (ii) if <process> fails,
> Camel should retry the route a configurable maximum number of times; (iii)
> If the route fails the maximum number of times, the initial message dequeued
> from 'queue.test' should be enqueued onto a dead-letter queue so that the
> next message on 'queue.test' can be processed.
> 
> My understanding is that this should be a 'transacted' route, and that I
> should use a TransactedErrorHandler. I have read the documentation here:
> http://camel.apache.org/transactionerrorhandler.html
> 
> But I'm afraid I cannot understand this rather intimidating sentence: "When
> the ValidationException is thrown from the validate order bean it is
> intercepted by the TransactionErrorHandler and it let the
> onException(ValidationException.class handle it so the Exchange is routed to
> this route and since we use handled(true) then the original exception is
> lowered (= cleared) and we transform the message into a fixed response that
> are returned to jetty endpoint that returns it to the original caller."
> 
> If anyone could offer an explanation, help or advice, or point out an
> example that acheives something similar to my desired behaviour, I would be
> very appreciative. 
> 
> We are using ActiveMQ as our JMS implementation, but would rather keep this
> JMS implementation non-specific.
> 
> Thanks.
> 
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/TransactedErrorHandler-requeue-JMS-message-to-DLQ-tp5716945.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
> 
>