You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "j vh (Jira)" <ji...@apache.org> on 2022/07/09 13:39:00 UTC

[jira] [Comment Edited] (CAMEL-18262) Templated route exception handling not working

    [ https://issues.apache.org/jira/browse/CAMEL-18262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17564579#comment-17564579 ] 

j vh edited comment on CAMEL-18262 at 7/9/22 1:38 PM:
------------------------------------------------------

Hi [~rhuanrcoha],
I've added a 7zip file with the sample code. This is a simplified version (single maven project) of what I described in the mail-archive article (two maven projects).
You can duplicate the problem in 2 different ways:
 * Run the RunRouteTest junit. This will mock out the route's file component and inject a test msg to show that the global exception handling is not invoked
 * Or just run the project via "mvn spring-boot:run" and copy a testfile into the input_directory in the project base directory. This will trigger the route to start. The testfile can have anything in it. A single line of text will suffice.

In either scenario, you'll see that the default rollback exception handling kicks in, and my handled(true) setup from L31, and the log on L32 are never executed from the class: CreateRoute.

Note: the reason for the exception is that the code is trying to send a REST POST to a REST API on port 9000 running on your localhost. (See the 2nd template parameter on L38 in the CreateRoute class).

I will also try out your suggestion for the custom error handler and let you know how that goes.


was (Author: JIRAUSER292531):
Hi [~rhuanrcoha],
I've added a 7zip file with the sample code. This is a simplified version (single maven project) of what I described in the mail-archive article (two maven projects).
You can duplicate the problem in 2 different ways:
 * Run the RunRouteTest junit. This will mock out the route's file component and inject a test msg to show that the global exception handling is not invoked
 * Or just run the project via "mvn spring-boot:run" and copy a testfile into the input_directory in the project base directory. This will trigger the route to start. The testfile can have anything in it. A single line of text will suffice.

In either scenario, you'll see that the default rollback exception handling kicks in, and my handled(true) setup from L31, and the log on L32 are never executed from the class: CreateRoute.

Note: the reason for the exception is that the code is trying to send a REST POST to a REST API on port 9000 running on your localhost. (See the 2nd template parameter on L38 in the CreateRoute class).

> Templated route exception handling not working
> ----------------------------------------------
>
>                 Key: CAMEL-18262
>                 URL: https://issues.apache.org/jira/browse/CAMEL-18262
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core
>    Affects Versions: 3.18.0
>         Environment: * Camel 3.18.0
>  * Spring-boot 2.7.1
>  * OpenJDK 11
>  * Maven 3.5.0
>            Reporter: j vh
>            Priority: Major
>         Attachments: camel-template-so.7z
>
>
> Using Route Templates as described here in the Camel docs: [route-template, |https://camel.apache.org/manual/route-template.html]I cannot get any exception handling to work unless I define it within the class that is constructing the template itself.
> Specifically,  trying to use global exception handling in the class that calls TemplatedRouteBuilder.builder() to build a route from my template. Expected exceptions are not caught.
> And there is no .onException() method implementation to customize the handling that could be called in the list of fluent methods starting with TemplatedRouteBuilder.build().
> I have already posted this, with my example code, in the Camel mailing list. Please have a look at the discussion here: [mail-archive|[https://lists.apache.org/thread/26kp2tpfbgj9mxpfdr106f36xyj51d7g]]
> This is the hi-level description from that mail article:
> {code:java}
> Hi-level overview:
> - 2 projects: 1 camel template base jar and 1 springboot camel application (that builds its route using the template from the other project).
> - the base jar builds a route template
> - the application jar builds a route using the template from the base jar
> - the desire here is to do some extra customization in the application (at templated-route creation time) to setup extra exception handling that is not included in the base template.
> - I have also tried to define global level exception handling using onException() in my application project's configure() method. But this is not catching anything either.
>  {code}
> There is a overview of the code in the mail article as well. But I also have a simplified single spring-boot test project with junit that I can provide if needed.



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