2

I would like to use OnException & OnComplition together in one route (Camel version 2.10.0.redhat-60024):

from("direct:camelTestEndpoint").
            onCompletion().
                log("onCompletion1").
                log("onCompletion2").
                log("onCompletion3").
            end().
            onException(Throwable.class).
                handled(true).
                log("onException").
            end().

            log("route")
            .throwException(new RuntimeException());

Although it does not work as I expect. Exception in main route causes onComplition route to stop after first processor (it is handled in PipelineHelper`s continueProcessing() method). Camel checks if exception was handled and if yes - stops the processing.

Output:

route
onException
onCompletion1

Is there I gentle way to say camel that it should skip this (without "CamelErrorHandlerHandled" property removal)?

Thanks

Yamahar1sp
  • 510
  • 1
  • 6
  • 13

2 Answers2

1

This is a bug in that version of Camel.

This has been fixed by CAMEL-7707.

As a workaround you would need to manually remove those details from the exchange, in the first process in the onCompletion you do.

For example something a like

    // must remember some properties which we cannot use during onCompletion processing
    // as otherwise we may cause issues
    Object stop = exchange.removeProperty(Exchange.ROUTE_STOP);
    Object failureHandled = exchange.removeProperty(Exchange.FAILURE_HANDLED);
    Object caught = exchange.removeProperty(Exchange.EXCEPTION_CAUGHT);
    Object errorhandlerHandled = exchange.removeProperty(Exchange.ERRORHANDLER_HANDLED);
Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • Fears were justified :) Yeah, I`m removing "CamelErrorHandlerHandled" and it works (I do not care about failures, do not use route stop and do need exception caught). Claus, thanks for great product support you provide. – Yamahar1sp Dec 17 '14 at 12:05
0
//STEP1: call Successful Route
   from("direct:Route_OnCompletion_OnSuccess")
        .onCompletion()
          .onCompleteOnly()
            .log("On Complete Passed")
            .to("direct:Route_OnSuccess")
        .end()
        .to("direct:Route_OnCompletion_OnFailure");

//STEP2: call Failure Route                
    from("direct:Route_OnCompletion_OnFailure")
        .onCompletion()           
            .onFailureOnly()    
                .log("On Complete Failed "+ body())
                .to("direct:Route_OnFailure")       
        .end() 
        .to("direct:Route_MainFlow");
vks
  • 179
  • 2
  • 5