You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dunnlow <du...@yahoo.com> on 2013/02/13 17:30:22 UTC

Re: Using Dead letter channel with ActiveMQ?

Claus, I've tried to avoid this issue, but it is back upon me.  

Basically, I'm using camel 2.10.3 now, Spring 3.1.2 and activemq 5.7) I am
consuming from an activemq broker which I do not control, and which does not
allow use of a DLQ - it is clustered, robust, etc, etc.  I want to make sure
that my route is successful before it is permanently removed from the queue. 
Currently, I use the Spring JmsTransactionManager with an activemq
RedeliveryPolicy.   However, this requests the creation of a DLQ after the
maximum delivery tries (which make the broker owners surly because they see
errors).

I am looking for the best strategy to handle this.  I've considered putting
a camel redelivery policy on top with one less retry (so that it sent the
msg to a dead letter channel before the last Spring retry).  I also
considered pulling the message off the queue and stuffing it somewhere
locally - but this is adding another point of failure.

Any other thoughts about how to take over the the dead letter channel so
that the message stays on the queue until either the route succeeds OR the
max retries is reached (and then stored locally to a file)?

Thanks for any thoughts,
-J



--
View this message in context: http://camel.465427.n5.nabble.com/Using-Dead-letter-channel-with-ActiveMQ-tp5723865p5727531.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using Dead letter channel with ActiveMQ?

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 13, 2013 at 6:45 PM, dunnlow <du...@yahoo.com> wrote:
> I have a solution that seems to be working.  I have assigned a context
> errorHandler and have a deliverypolicy that has a dead letter uri (a route
> that dumps to a file), like:
>
>     <camelContext.... errorhandlerRef="errorHandler"/>
>
>     <errorHandler id="errorHandler" type="DeadLetterChannel"
> deadLetterUri="direct:dumpToFile" useOriginalMessage="true">
>         <redeliveryPolicy maximumRedeliveries="5"....... />
>     </errorHandler>
>
>     <route>
>        <from:jms:testQueue>
>        <transacted>
>        <bean:ref="myBean" method="sendToWebService"/>
>     </route>
>
>
> When a message fails 5 times (to test I am shutting down the web service, so
> there is a connection exception thrown), it is routed to my "dumpToFile"
> route.
>
> I'm still using the Spring JmsTransactionManager in my JMS config for the
> connection factory because if I don't and camel shuts down during the
> retries, the message is lost (pulled off the queue).
>
> A few questions:
>
> 1) My ActiveMQ redeliveryPolicy seems to be getting ignored.  I believe that
> the camel error handler is intercepting so that spring/activemq does not see
> the rollback.  Does this seem correct?
>

Yes the Camel error handler kick-in first. And only the AMQ afterwards.
But because you use a DeadLetterChannel in Camel, then Camel will
remove any traces of error/exception.
So the AMQ seems the message as "commit" and not "rollback".



> 2) Does anyone see any issues with this approach?
>
> Claus, meant to mention, I never found a JMSRedeliveryCounter.
>
> Thanks again,
> -J
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-Dead-letter-channel-with-ActiveMQ-tp5723865p5727544.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Using Dead letter channel with ActiveMQ?

Posted by dunnlow <du...@yahoo.com>.
I have a solution that seems to be working.  I have assigned a context
errorHandler and have a deliverypolicy that has a dead letter uri (a route
that dumps to a file), like:

    <camelContext.... errorhandlerRef="errorHandler"/>

    <errorHandler id="errorHandler" type="DeadLetterChannel"
deadLetterUri="direct:dumpToFile" useOriginalMessage="true">
        <redeliveryPolicy maximumRedeliveries="5"....... />
    </errorHandler>

    <route>
       <from:jms:testQueue>
       <transacted>
       <bean:ref=&quot;myBean&quot; method=&quot;sendToWebService&quot;/>
    </route>


When a message fails 5 times (to test I am shutting down the web service, so
there is a connection exception thrown), it is routed to my "dumpToFile"
route.

I'm still using the Spring JmsTransactionManager in my JMS config for the
connection factory because if I don't and camel shuts down during the
retries, the message is lost (pulled off the queue).  

A few questions:

1) My ActiveMQ redeliveryPolicy seems to be getting ignored.  I believe that
the camel error handler is intercepting so that spring/activemq does not see
the rollback.  Does this seem correct?

2) Does anyone see any issues with this approach?

Claus, meant to mention, I never found a JMSRedeliveryCounter.

Thanks again,
-J



--
View this message in context: http://camel.465427.n5.nabble.com/Using-Dead-letter-channel-with-ActiveMQ-tp5723865p5727544.html
Sent from the Camel - Users mailing list archive at Nabble.com.