Error handling across Camel route builders

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Error handling across Camel route builders

Sebastian Czort
Hi,

I have a question about best practices on error handling in Camel route A,
which calls Camel route B.

A and B are different route builder instances

class A extends RouteBuilder {
  configure() {
    onException(Exception.class)
      .handled(true)
      // produce general error message

    from("direct:a")
      .. // some processing, which could throw an exception
      to("direct:b")
      .. // processing after b
  }
}

class B extends RouteBuilder {
  configure() {
    onException(AuthenticationException.class)
      .onRedelivery( /** login */);

      from("direct:b")
        // some processing, which could throw an exception
        // some processing, which could throw an authentication exception
  }
}

Is there a best practice on how to set this up in Camel, so that general
error messages are produced in A for non-authentication exceptions thrown
in routes A or B?

Please note that I would like to have no processing done in route A after
the call to route B, if the call to route B throws an exception.

Thank you in advance!

Sebastian Czort