Yeah I can inherit classes but I don't see where that gets me anywhere. How to I declare the onException part and then use it in a route later? I know the route DSL just builds a map that is later instantiated by the camel engine. I want to build a part and then use it. Something like this:
Fragment generalExceptionHandling = .onException(Exception.class).useOriginalMessage().handled(true) .setHeader(Exchange.FAILURE_ROUTE_ID, property(Exchange.FAILURE_ROUTE_ID)) .setHeader(Exchange.EXCEPTION_CAUGHT, simple(this.STORE_MSG_EXPR)) .to(ExchangePattern.InOnly,endpointAMQ(QUEUE_CASE_AUTOMATION_DEAD)).end() and then later from(endpointAMQ(QUEUE_CASE_INBOX).fragment( generalExceptionHandling).to(""); That way I can declare the fragment elsewhere and add it on to my route later. This would keep me from having to cut and paste code all over creation. *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>* On Fri, Nov 8, 2013 at 2:25 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > 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 >