Camel - How I can define a errorHandler and can use includeRoutes? -
i define routes in subclasses , them in 1 routebuilder
includeroutes()
. want insert default errorhandler error message:
errorhandler must defined before routes in routebuilder
this code:
public class defaultroutes extends routebuilder { public void configure() throws exception { errorhandler(deadletterchannel("direct:deadletter").maximumredeliveries(3)); from("direct:deadletter").id("deadletter") .errorhandler(defaulterrorhandler().disableredelivery()) .log("${exception.stacktrace}") .setheader("errormessage",simple("${exception}",string.class)) .setheader("errorstacktrace",simple("${exception.stacktrace}",string.class)) .to("activemqwithouttransactions:errors"); ... ... for(string module: globalconfig.getloadedmodules()) { ... includeroutes(routes); } ... }
i had test this:
public class defaultroutes extends routebuilder { public void configure() throws exception { routebuilder errorhandler = new routebuilder() { public void configure() { errorhandler(deadletterchannel("direct:deadletter").maximumredeliveries(3)); from("direct:deadletter").id("deadletter") .errorhandler(defaulterrorhandler().disableredelivery()) .log("${exception.stacktrace}") .setheader("errormessage",simple("${exception}",string.class)) .setheader("errorstacktrace",simple("${exception.stacktrace}",string.class)) .to("activemqwithouttransactions:errors"); } }; includeroutes(errorhandler); ... ... for(string module: globalconfig.getloadedmodules()) { ... includeroutes(routes); } ... }
but throw same error message! can do, errorhandler work?
thank you
i think problem described in comments of issue https://issues.apache.org/jira/browse/camel-5612.
if use global scoped errorhandler have ensure should following:
- errorhandler
- errorhandler
- route
- route
and not:
- errorhandler
- route
- errorhandler
- route
kind regards, soilworker
Comments
Post a Comment