I've defined an Error Handler, which applies to multiple routes i.e.
errorHandler(transactionErrorHandler()
.maximumRedeliveries(5)
.log("SOMETHING USELESS");
from(file1)
.id(route1)
.transacted()
.process(new SpecificProcessor1());
from(file2)
.id(route2)
.transacted()
.process(new SpecificProcessor2());
When an Exception occurs inside one of the SpecificProcessor classes, the following is logged:
[10-Jan-2014 15:08:59.449] [Error] SOMETHING USELESS: Failed delivery for (MessageId: ID-BLAH BLAH). On delivery attempt: 1 caught: java.lang.Exception: cannot do whatever I'm supposed to do
Now I would like to print something useful to help identify whether the Exception has happened in route1 or route2 i.e.:
[10-Jan-2014 15:08:59.449] [Error] ROUTE 1: Failed delivery for (MessageId: ID-BLAH BLAH). On delivery attempt: 1 caught: java.lang.Exception: cannot do whatever I'm supposed to do
How can I achieve that?
I have tried things like .log(${routeId}), but it doesn't work.
Many thanks!
You can add thread name to your appender configuration. For example %t for log4j:
You will see something like:
I guess it is enough to identify the route