Hi Thanks for reporting and providing an unit test to reproduce the issue. I have logged a ticket https://issues.apache.org/jira/browse/CAMEL-7707
On Fri, Aug 15, 2014 at 6:19 PM, jorabin <jo.ra...@wiforia.com> wrote: > (Amplification of a less specific post > <http://camel.465427.n5.nabble.com/Behavior-of-onCompletion-for-exception-fault-and-stop-td5754257.html> > ) > a) following exception the onCompletion route runs but stops after the first > processor (seemingly because the property CamelErrorHandlerHandled is in the > copied exchange) > b) onCompletion following exception runs the onCompleteOnly() route not the > onFailureOnly() route > c) following stop() the onCompletion doesn't run (seemingly because of the > presence of CamelRouteStop property in the copied exchange) > A work around to a) and c) is to remove the relevant properties - in the > following example in a RoutePolicy > A unit test demonstrating this follows: > @Test public void onCompletionStopTest () throws Exception { > RouteBuilder b = new RouteBuilder() { @Override public > void configure() throws Exception { > onCompletion().onFailureOnly() .log("failing > ${body}") .log("continuing to fail ${body}") > .to("mock:failed"); onCompletion().onCompleteOnly() > .log("completing ${body}") .log("continuing to > complete ${body}") .to("mock:complete"); > onException(Exception.class) .log("Handling > exception") .handled(true) > .end(); from("direct:input") > .routePolicy(new RoutePolicySupport() { @Override > public void onExchangeDone(Route route, Exchange exchange) { > exchange.removeProperty(Exchange.ERRORHANDLER_HANDLED); > exchange.removeProperty(Exchange.ROUTE_STOP); } > }) .choice() > .when(simple("${body} == 'stop'")) > .log("stopping") .stop() > .when(simple("${body} == 'fault'")) > .log("faulting") > .setFaultBody(constant("faulted")) > .when(simple("${body} == 'except'")) > .log("excepting") .throwException(new > Exception("Exception requested")) .end() > .log("finishing") .to("mock:end"); } > }; context().addRoutes(b); MockEndpoint end = > getMockEndpoint("mock:end"); end.expectedMessageCount(1); > MockEndpoint complete = getMockEndpoint("mock:complete"); // except > should count as failure not completion > complete.expectedBodiesReceived("finish", "stop", "except"); > MockEndpoint failed = getMockEndpoint("mock:failed"); > failed.expectedBodiesReceived("faulted"); > template().sendBody("direct:input","finish"); > template().sendBody("direct:input","stop"); > template().sendBody("direct:input","fault"); > template().sendBody("direct:input","except"); Thread.sleep(1000); > assertMockEndpointsSatisfied(); } > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Incorrect-behavior-of-onCompletion-for-exception-and-stop-tp5755272.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@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/