I have a number of situations where i have different parts of a route that repeat consistently but Id rather not create separate routes or direct calls because I want avoid a bottleneck. If i create 50 routes concurrently consuming off of one queue and route them all through the same direct, the direct itself would become a bottleneck. What I would like to do is to create the route parts in a helper method and then attach them to the route. For example:
.setHeader("X", simple("${header.url}") .setHeader("y", simple("${header.something_else}") ... and so on for 10 headers. .to("http:myendpoint.com") What I would like to do is declare a method that contains all of that and then do something like: from("...") // so on and rest of non-common route .attach(myRoutePartBuilder()) .to(" ... ") // and so on. One example of how this effects me is that I have a number of different handlers that resemble the following: .onException(Exception.class).useOriginalMessage().handled(true).maximumRedeliveries(0) // catch exceptions .setHeader(Exchange.FAILURE_ROUTE_ID, property(Exchange.FAILURE_ROUTE_ID)) // set route that failed .setHeader(Exchange.EXCEPTION_CAUGHT, simple("${exception.stacktrace}")) // Store reason for error .to(ExchangePattern.InOnly, endpointAMQ(QUEUE_CASE_AUTOMATION_DEAD)).end() // to DLQ I have about 3 versions of this that are slightly different and used in over 2 dozen routes. I have to copy paste that part all over. Furthermore I cant do this as a global handler because the variants are handling the same exceptions in slightly different ways. What I want is: .onException(buildExceptionHandler1()) .to("...") // so on and .onException(buildExceptionHandler2()) .to("...") // so on So any ideas how this could be accomplished with 2.12.x? If not, any advice on how to handle these issues without creating performance bottlenecks? TIA *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>*