1

When using camel, I can use

onException(Excepction.class).process(new ExceptionListener())

to react to exceptions on routes. Within my ExceptionListener I can get the exception, but is there a way to find out where exactly the exception was thrown?

I want to destinguish multiple error sources programmatically, so I can react differently to a servicecall error for service xyz, servicecall for abc and a bean call. I know I could just wrap every service call in a try-catch-block, but I would have to do this a lot and my route would end up quite chunky.

Marc
  • 33
  • 7

1 Answers1

0

The doc says:

When Camel error handler handles an error such as Dead Letter Channel or using Exception Clause with handled=true, then Camel will decorate the Exchange with the route id where the error occurred.

So you can get the id of the involved route via:

String failedRouteId = exchange.getProperty(Exchange.FAILURE_ROUTE_ID, String.class);
TacheDeChoco
  • 3,683
  • 1
  • 14
  • 17