I have parent router that calls other routers. The parent router has all the exception handling logic. In all child routers, on exception, I want to just add properties in the exchange object and leave the actual exception handling in the parent(main) router.
Example:
public class ParentRouter extends RouteBuilder {
@Override
public void configure() throws Exception {
onException(CustomException.class)
.process(new ExceptionProcessor())
.handled(true);
from("direct:parent-route").to("direct:child-route");
from("direct:child-route")
.onException(CustomException.class)
.process(new Processor(){
@Override
public process(Exchange exchange){
exchange.setProperty("childExceptionFlg", "true");
}
});
}
As per my requirement, when CustomExpection is thrown in the child router, it should add a property to the exchange object and the final handling code needs to be executed in the ExceptionProcessor in the parent router.