How to catch and process the exception specific to route?
Issue
- We have a route like
onException(Exception.class).handled(true)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
LOGGER.info("*************inside general exception");
Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
LOGGER.error("Exception caught:{}", e);
exchange.getIn().setBody("General Exception");
}
});
paymentService = "jetty:http://localhost:9191/someUrl";
from(paymentService).threads(50, 100)
.to("direct:a");
from("direct:a")
.doTry()
.process(processor2)
.doCatch(Exception.class).process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
LOGGER.info("*********JPA exception");
exchange.getIn().setBody("JPA exception");
}
})
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
LOGGER.info("*********End of process");
exchange.getIn().setBody("End of process");
}
});
- In the second route it throws the exception at this line ".process(processor2)" we are expecting to get "JPA exception" in the response but getting "General Exception". please suggest how to handle exception specific to the route if the exception handling is already declared.
Environment
- Red Hat JBoss Fuse
- 6.2.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
