Harish Annamalai created CAMEL-19441:
----------------------------------------

             Summary: Camel does not continue routing after doTry..doCatch..end 
block in case of Direct Component.
                 Key: CAMEL-19441
                 URL: https://issues.apache.org/jira/browse/CAMEL-19441
             Project: Camel
          Issue Type: Bug
          Components: camel-core, camel-core-api
    Affects Versions: 3.14.7
            Reporter: Harish Annamalai


Camel Does not continue routing with a doTry..doCatch..end block with direct 
component with a onException clause defined in it.

I have created two routes namely, MainRoute and childRoute. 

The ChildRoute consists of an onExceptionBlock, with "handled(true)" clause. 

when an exception occurs in the childRoute, the onExceptionBlock executes and 
the chlidRoute execution stops. However, the flow doesn't continue on the 
mainRoute.

Camel DSL for the two routes:

{{from("timer://runOnce?repeatCount=1&delay=1000")}}
{{                .id("MainRoute")}}
{{                .onException(Exception.class)}}
{{                .setBody(constant("ExceptionBLock"))}}
{{                .to("log://error")}}
{{                .handled(true)}}
{{                .end()}}
{{                .setHeader("routeLocation", constant("MainRoute"))}}
{{                .setBody(constant("MainRoute"))}}
{{                .to("log://main")}}
{{                .doTry()}}
{{                    .to("direct://childRoute")}}
{{                .doCatch(Exception.class)}}
{{                    .to("log://ExceptionCatchBlock")}}
{{                .end()}}
{{                .to("log://afterTryCatch")}}
{{                .end();}}{{        from("direct://childRoute")}}
{{                .id("ExceptionRoute")}}
{{                .onException(Exception.class)}}
{{                .useOriginalMessage()}}
{{                .handled(true)}}
{{                .setBody(constant("Child Exception Block"))}}
{{                .to("log://childExceptionSubProcess")}}
{{                .end()}}
{{                .setHeader("routeLocation", constant("exceptionRoute"))}}
{{                .setBody(constant("Exception Route"))}}
{{                .to("log://beforeException")}}
{{                .throwException(new RuntimeException("A runtime exception"))}}
{{                .to("log://afterException")}}
{{                .end();}}{{ }}

 

{{Output:}}
{quote}{{2023-06-13 16:30:20.876  INFO 3500 --- [timer://runOnce] main          
                           : Exchange[ExchangePattern: InOnly, BodyType: 
String, Body: MainRoute]}}
{{2023-06-13 16:30:20.880  INFO 3500 --- [timer://runOnce] beforeException      
                    : Exchange[ExchangePattern: InOnly, BodyType: String, Body: 
Exception Route]}}
{{2023-06-13 16:30:20.883  INFO 3500 --- [timer://runOnce] 
childExceptionSubProcess                 : Exchange[ExchangePattern: InOnly, 
BodyType: String, Body: Child Exception Block]}}
{quote}
{{In the above routes, when the exception occurred in the childRoute, the 
onException block in childRoute executes, however, the 
}}{color:#FF0000}{{.to("log://afterException") 
}}{color}{color:#172b4d}{{doesn't execute.}}{color}{{{}{}}}

{color:#172b4d}{{As per the documentation, the doTry..doCatch block mimic the 
Java, try..catch block. }}{color}

{color:#172b4d}{{Here the routing breaks on the mainRoute.}}{color}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to