You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Chris Melikian <ch...@melikian.net> on 2014/09/08 17:16:03 UTC
Idempotent consumer, removeOnFailure=true and exception handling
Hi,
So i'm using Camel 2.13.1 and the JDBC Idempotent Repository and I'd like to
use the removeOnFailure
=true option to be able to replay the transaction on failure.
My question is whether implementing an onException clause which handles an
exception would stop the removeOnFailure option from being carried out as
the failure is being marked as 'handled=true'. Here is my onException clause
in Spring XML:-
<camel:onException>
<camel:exception>java.lang.Exception</camel:exception>
<camel:redeliveryPolicy logStackTrace="true"
disableRedelivery="true" logExhausted="true" />
<camel:handled>
<constant>true</constant>
</camel:handled>
<camel:log
message="Transaction has failed and is being handled by the exception
handler. Received message [${exception}], full stack trace
[${exception.stacktrace}]"
loggingLevel="ERROR"
logName="com.lgim.sophis.unrecoverableerror"></camel:log>
</camel:onException>
In the above case would the camel_messageprocessed table entry for the
failing exchange be removed?
Here is my route for idempotency:-
<route id="idempotentTransactionsRoute">
<from uri="direct:filterForIdempotency" />
<idempotentConsumer messageIdRepositoryRef="jdbcIdempotentRepository">
<el>${in.body.ID}</el>
<to ref="direct:processTransaction" />
</idempotentConsumer>
<stop />
</route>
Any help appreciated!
--
View this message in context: http://camel.465427.n5.nabble.com/Idempotent-consumer-removeOnFailure-true-and-exception-handling-tp5756198.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Idempotent consumer, removeOnFailure=true and exception
handling
Posted by Chris Melikian <ch...@melikian.net>.
Thanks Claus. I did try it and with Camel debug logging on I expected to see
the message
LOG.debug("Removed from repository as exchange failed: {} with id: {}",
exchange, messageId);
from the org.apache.camel.processor.idempotent.IdempotentOnCompletion class
and indeed the entry is not being removed from the camel_messageprocessed
table.
Does the error have to occur within the idempotentConsumer element? If so
then I assume that the camel_messageprocessed entry is already committed and
I have to delete the entry myself in my exception handler?
--
View this message in context: http://camel.465427.n5.nabble.com/Idempotent-consumer-removeOnFailure-true-and-exception-handling-tp5756198p5756231.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Idempotent consumer, removeOnFailure=true and exception handling
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yes removeOnFailure will be called even if the exception was handled.
On Mon, Sep 8, 2014 at 5:16 PM, Chris Melikian <ch...@melikian.net> wrote:
> Hi,
>
> So i'm using Camel 2.13.1 and the JDBC Idempotent Repository and I'd like to
> use the removeOnFailure
> =true option to be able to replay the transaction on failure.
>
> My question is whether implementing an onException clause which handles an
> exception would stop the removeOnFailure option from being carried out as
> the failure is being marked as 'handled=true'. Here is my onException clause
> in Spring XML:-
>
> <camel:onException>
> <camel:exception>java.lang.Exception</camel:exception>
> <camel:redeliveryPolicy logStackTrace="true"
> disableRedelivery="true" logExhausted="true" />
> <camel:handled>
> <constant>true</constant>
> </camel:handled>
> <camel:log
> message="Transaction has failed and is being handled by the exception
> handler. Received message [${exception}], full stack trace
> [${exception.stacktrace}]"
> loggingLevel="ERROR"
> logName="com.lgim.sophis.unrecoverableerror"></camel:log>
> </camel:onException>
>
> In the above case would the camel_messageprocessed table entry for the
> failing exchange be removed?
>
> Here is my route for idempotency:-
>
> <route id="idempotentTransactionsRoute">
> <from uri="direct:filterForIdempotency" />
> <idempotentConsumer messageIdRepositoryRef="jdbcIdempotentRepository">
> <el>${in.body.ID}</el>
> <to ref="direct:processTransaction" />
> </idempotentConsumer>
> <stop />
> </route>
>
> Any help appreciated!
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Idempotent-consumer-removeOnFailure-true-and-exception-handling-tp5756198.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/