JMS only stores body + headers. Any properties and the likes are not
stored. Hence what you move to jms:errors in the Message body.
If you want to store the Exception as well you gotta serialize it and
store it as a header etc.

You can try the transferExchange=true option on the JMS endpoint, then
Camel will store the entire Exchange including the Exception.
See more at the wiki page
http://camel.apache.org/jms.html

On Wed, Feb 10, 2010 at 6:35 PM, Nick Chistyakov <chiko...@gmail.com> wrote:
> 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



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to