Hello camel riders! I found a problem on getting an exception object out of exchange.
If I declare a route like this: onException(Exception.class) .handled(true) .to("jms:errrors"); Then, I should be able to write a code like this: Exchange e = consumer.receive("jms:errrors", 1000); and I can access an exception by: e.getProperty(Exchange.EXCEPTION_CAUGHT); The problem is that there is no exception object (null instead of it) in case when I run the system composed of set of modules that all have the route above to handle exceptions. The simple unit test, where everything is one context will pass. But will fail in more complicated cases. The exchange will contain a message that was not delivered but somehow it will miss any information about exception. If I modify my route :) onException(Exception.class) .onWhen(new Predicate() { @Override public boolean matches(Exchange exchange) { exchange.getIn().setBody(exchange.getException()); return true; } }) .handled(true) .to("jms:errors"); I will yet get it (instead of original message body though) Where can I find a code that finally serializes the exchange and sends it to destination? I tried to debug it but I'm not o experienced in camel internals, so I didn't find it. I would like to track what is going on. To make my point 100% clear I provided a small test project. It's a maven project so anyone can easily run it. It contains a Router and 2 test: OnExceptionGreenTest and OnExceptionRedTest one is passing one is not. Best regards, Nick
onexception.tar.bz2
Description: BZip2 compressed data