Hi Raymond,
Thanks for the suggestion. But seems that defining exception handling via the 
RouteConfigurationBuilder doesn't work either.
Let me further explain with some piece of code.
Maybe this will trigger some thoughts as you'll be able to see what I'm trying 
to do here.

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.

Thanks,
jvh

ps: the post in between here by Ephemeris Lappis seems to be targeted for a 
different thread.   :-)

Code snippets:
1) Base project route configure method:

    @Override
    public void configure() {
      final RouteTemplateDefinition rtd = routeTemplate("route-template-1")
            .templateParameter("queue-name")
            .templateParameter("rest-endpoint")

            .from("jmsBroker:queue:{{queue-name}}")
            // .routeConfigurationId("test-route-configuration-id")    // tried 
to add (and remove the local .onException from here)

           .onException(ConnectException.class)
              .handled(false)
              .log(LoggingLevel.ERROR, logger, "--> Exception: 
${exception.message}, Delivery was rolled back")
              .end()

         .process(restHeaderProcessor)
         .to("{{rest-endpoint}}")
         .log(LoggingLevel.INFO, logger, "Message sent, ResponseCode: 
${header.CamelHttpResponseCode}");
    }

2) Application project configure method, building route from base project 
template:

    @Override
    public void configure() {
      final String route = TemplatedRouteBuilder.builder(camelContext, 
"route-template-1")
            .routeId("route-jms-to-rest")
            .parameter("myQueue")
            .parameter("http://localhost:9000/myRestEndpoint";)
            .add();
      log.info("buildTemplatedRoute() created templated route: {}", route);
    }

3)  Application project Configuration spring boot component class:

@Component
public class MyCustomErrorHandler extends RouteConfigurationBuilder {

   @Override
   public void configuration() throws Exception {
      routeConfiguration("test-route-configuration-id")
      .onException(Exception.class)
         .handled(true)  // discard the msg
         .log(LoggingLevel.INFO, ">>>>> Hit this custom error handler: 
${exception.message}")
         .end();
   }
}


________________________________________
From: ski n <raymondmees...@gmail.com>
Sent: June 17, 2022 8:28 AM
To: users@camel.apache.org
Subject: Re: Apache Camel Exception Handling doubt

Hi,

It's good to provide a code example to see what you tried.

Have you also tried to combine it with route configuration?

https://camel.apache.org/manual/route-configuration.html

This is available from 3.12.

Raymond

On Thu, Jun 16, 2022 at 7:43 PM j vh <jvh...@hotmail.com> wrote:

> Hello,
> btw... I'm using Camel 3.13.0 for this work.
> ...jvh003

Reply via email to