You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by andrericos <an...@gmail.com> on 2014/06/30 23:23:27 UTC
OnCompletion and rollbacked transaction.
Hi,
I'm facing a problem using OnCompletion and a Transacted route.
Let me show an example:
this.from("servlet:///test").routeId("CamelTestRoute")
.onCompletion()
.bean(this.logCompletionRoute)
.end()
.onException(Exception.class)
.log(LoggingLevel.ERROR, this.log, "Error on processing
message. Sending Rollback command!")
.log(LoggingLevel.ERROR, this.log,
"${exception.stacktrace}")
*/.rollback()/*
.handled(true)
.end()
.transacted(RouteTransactionConfiguration.PROPAGATION_REQUIRED)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new Exception();
}});
When I use the "rollback()" method, the logCompletionRoute bean is not
executed. When a erase that line the onCompletion bean is executed at the
route's end.
Is it a bug or a wrong configuration (or understanding)?
Thanks,
André Souza
--
View this message in context: http://camel.465427.n5.nabble.com/OnCompletion-and-rollbacked-transaction-tp5753080.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: OnCompletion and rollbacked transaction.
Posted by andrericos <an...@gmail.com>.
Well...
I tried to find where the camel stops to compute the route and I found this
code in RedeliveryErrorHandler.java:
// compute if we are exhausted, and whether redelivery is
boolean exhausted = isExhausted(exchange, data);
boolean redeliverAllowed = isRedeliveryAllowed(data);
// if we are exhausted or redelivery is not allowed, then deliver to failure
processor (eg such as DLC)
if (!redeliverAllowed || exhausted) {
After that Camel stops my route.
So, I tried to do my bean execute before the route was marked to
ROLLBACK_ONLY.
Using pipeline inside the onException I could do that:
...
.onCompletion()
.bean(this.logCompletionRoute)
.end()
.onException(Exception.class)
.handled(true)
*.pipeline()
.log(LoggingLevel.ERROR, this.log, "Error on processing
message. Sending Rollback command!")
.log(LoggingLevel.ERROR, this.log,
"${exception.stacktrace}")
.bean(this.logCompletionRoute)
.end()*
.rollback()
.end()
...
Is there some more elegant solution?
Thanks
André Souza
--
View this message in context: http://camel.465427.n5.nabble.com/OnCompletion-and-rollbacked-transaction-tp5753080p5753088.html
Sent from the Camel - Users mailing list archive at Nabble.com.