If I understood you correctly, you want to know from where this Exchange which holds the exception, have you tried something like `exchange.getFromEndpoint` or `exchange.getFromRouteId`? Which as I understood should gives from which endpoint this exchange has been originated from. However, I think `Exchange.FAILURE_ENDPOINT` will contain the information about the last time Camel has sent the exchange to, hence I think you would see this information after a `to` route. However I am not 100% sure though.
On Wed, 28 Aug 2019 at 07:38, Wang Yan <wyan...@gmail.com> wrote: > Hello all, > > > OnException block , the TechnicalException will be caught, this > exception could come > > from Route A or Route B , my question is , Is it possible for on Exception > block > > to figure out where the TechnicalException is originated from ? for > example from which Route or from which Endpoint? > > I tried to use exchange.getProperty(Exchange.FAILURE_ENDPOINT) or > exchange.getProperty(Exchange.FAILURE_ROUTE_ID) > > but they both print out null value > > Any hints or suggestions are more than welcome! > > > > > onException(TechnicalException.class) > .log(LoggingLevel.ERROR, "TechnicalException caught > globally ") > .redeliveryDelay(3000) > .maximumRedeliveries(3) > //Exchange.FAILURE_ROUTE_ID > .onRedelivery(exchange -> { > LOG.info("onRedelivery {} , failed endpoint id {} > exception type {}", > exchange.getIn().getHeader(Exchange.REDELIVERY_COUNTER) > ,exchange.getProperty(Exchange.FAILURE_ENDPOINT) , > exchange.getProperty(Exchange.EXCEPTION_CAUGHT).getClass()); > }) > .handled(true) > .to("activemq:queue:mydeadletterqueue") > .log(LoggingLevel.ERROR, "technical exception send to > mydeadletterqueue") > .end(); > > > route A > > route B >