camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kraythe ." <>
Subject Looking for ideas to reduce code volume and duplication
Date Tue, 01 Apr 2014 14:51:42 GMT

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
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: **

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message