I am trying to build a application with several camel routes which re use many common routes internally. Hence, I am trying to segregate the routes in several different Rou
Based on the accepted answer, I found a cleaner way to implement exception handling, so you don't have to call super.configure() in every route. Just call a method that handles onException in the constructor of the base class.
//Base class that does exception handling
public abstracExceptionRouteBuildert class BaseAbstractRoute extends RouteBuilder {
protected BaseAbstractRoute() {
handleException();
}
private void handleException() {
onException(Exception.class).handled(true).to("mock:error");
}
}
//Extend the base class
public class MyRouteBuilder extends BaseAbstractRoute {
@Override
public void configure() throws Exception {
from("direct:start").throwException(new Exception("error"));
}
}