Greetings: I have dozens of routes currently in our system and they have one of two variants of the following code:
.onException(Exception.class).useOriginalMessage().handled(true) // catch exceptions .setHeader(Exchange.FAILURE_ROUTE_ID, property(Exchange.FAILURE_ROUTE_ID)) // set route that errored .setHeader(Exchange.EXCEPTION_CAUGHT, simple("${exception.stacktrace}")) // Store reason for error .to(ExchangePattern.InOnly, endpointAMQ(config.queueCaseAutomationDead())).end() // to DLQ The problem is I am getting more than annoyed at having to copy paste this all over the place but since there are a couple of variants, I cant declare a global handler. Making a direct is all well and good but doesnt really buy me much as I still have half the handler on every route. Any ideas how I could reduce code volume here ? *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of: Hardcore Java (2003) and Maintainable Java (2012)* *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 <http://www.linkedin.com/pub/robert-simmons/40/852/a39>*