You can have a abstract base route builder class where you have shared onException and whatnot. And then just call super.configure() in your route classes
On Thu, Nov 7, 2013 at 10:20 PM, kraythe . <kray...@gmail.com> wrote: > Greetings, I have the following exception handling code on every route that > I make. Since it is cut and paste I would love to factor it out into some > kind of route fragment that I could use in each route that is using it. Any > suggestions on how I could go about this? Direct wont work and the error > handler cannot be configured the way I want it (not to mention that there > are a couple of routes that do slightly different things. Thanks for your > time and here is the route snippet: > > .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(this.STORE_MSG_EXPR)) // > Store reason for error > > .to(ExchangePattern.InOnly, > endpointAMQ(QUEUE_CASE_AUTOMATION_DEAD)).end() > // to DLQ > > *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>* -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen