You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sandeepreddip <sa...@gmail.com> on 2014/06/27 19:39:35 UTC
Camel Exception Processing onRedelivery
Hi,
I' m trying to audit failures to a table in database on every *retry*
caused by an exception.
I have an exception handler that is invoked on exception
(HttpOperationFailedException in my case). As expected, a retry is executed
every 5 seconds, the * Exception from Exchange in the processor*
CamelRestResponseProcessor (* route below*) is always *null *and the route
*to("mybatis:insertProduct?statementType=Insert") * is invoked only ofter
all the retries are done.
Is it possible to log each failure before camel does a retry? My idea was
to create custom object in the processor and feed it as input to mybatis.
errorHandler(defaultErrorHandler().onRedelivery(new
CamelRestResponseProcessor()).to("mybatis:insertProduct?statementType=Insert")
.useOriginalMessage().maximumRedeliveries(5).redeliveryDelay(5000));
from("timer:foo?period=1000").process(new
MessageProcessor()).to("http4://localhost:8080/cts-rest/cts/users")
.bean( CamelBeanBinding.class,"invokeMethod7");
*PROCESSOR*
public class CamelRestResponseProcessor implements Processor {
private static final Logger logger =
Logger.getLogger(CamelRestResponseProcessor.class);
/**
*
*/
public CamelRestResponseProcessor() {
}
@Override
public void process(Exchange exchange) throws Exception {
Message message = exchange.getIn();
logger.debug(" Headers" + message.getHeaders());
logger.debug(" Exception " +exchange.getException());* //ALWAYS null*
}
}
*I could achieve it with doTry.. doCatch with the route below, but
onException /onRedelivery doesn't seem to work inline with a route.*
from("timer:foo?period=1000").process(new MessageProcessor()).doTry().
to("http4://localhost:8080/cts-rest/cts/users").doCatch(HttpOperationFailedException.class)
.process(new
CamelRestResponseProcessor()).to("mybatis:insertProduct?statementType=Insert").doFinally().end();
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Exception-Processing-onRedelivery-tp5752976.html
Sent from the Camel - Users mailing list archive at Nabble.com.