You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Harish Annamalai (Jira)" <ji...@apache.org> on 2023/06/13 12:32:00 UTC

[jira] [Reopened] (CAMEL-19441) Camel does not continue routing after doTry..doCatch..end block in case of Direct Component.

     [ https://issues.apache.org/jira/browse/CAMEL-19441?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Harish Annamalai reopened CAMEL-19441:
--------------------------------------

[~davsclaus] : Thanks for your response. I apologise for re-opening the issue, as I feel the bug report was not properly presented.

From your response: "The child route handles(true) the exception so there is no exception from the outer route point of view", that is ok, but the problem is the mainRoute doesn't continue to execute. The *mainRoute* also stops execution. 

That is if the childRoute doesn't have any exception handling, the doCatch in mainRoute executes, and the mainRoute also continues execution. 

If the childRoute, has exception handling, the mainRoute also stops execution.

What I feel like a bug is, the regardless of the exception handling in childRoute, the mainRoute needs to continue. Here, the mainRoute also stops execution.

> 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
>            Priority: Major
>
> 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:}}
> {{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]}}
> {{In the above routes, when the exception occurred in the childRoute, the onException block in childRoute executes, however, the {color:#ff0000}.to("log://afterException") of the mainRoute {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. Contrary to the try..catch of java, where exception handling inside a called method doesn't affect the caller.}}{color}



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