Hi,

I think I've got it ...

On my RouteBuilder-class (see below) I try to catch UnmarshalException in
one and all other excpetions in the other onException call.


        onException(UnmarshalException.class)
        .useOriginalBody()
        .handled(true)
            .to("log:onException(UnmarshalException.class)?level=INFO")
        .end();

        onException(Exception.class)
        .useOriginalBody()
        .handled(true)
            .to("log:onException(Exception.class)?level=INFO")
        .end();

        from("activemq:publish?exchangePattern=InOnly&transacted=true")
            .routeId(Publish2CenterRouteBuilder.ROUTE_ID)
            .transacted()
                .process(new Publish2CenterProcessor())
                .multicast()
                    .pipeline()
                       
.to("activemq:BonData?exchangePattern=InOnly&transacted=true")
                    .end()
                    .pipeline()
                       
.to("activemq:NonBonData?exchangePattern=InOnly&transacted=true")
                    .end()
                 .end()
        .end();


In my processor/bean (Publish2CenterProcessor) if a UnmarshalException is
thrown I use the constructor that put in a nested exception (in that case a
XMLException from XMLBeans)!!


        throw new UnmarshalException("Could not unmarshal body to XML3!",
exception);


As descriped in http://camel.apache.org/exception-clause.html camel will
"start from the bottom (nested caused by) and recursive up in the exception
hierarchy to find the first matching onException clause". In my case the
nested exception (XMLException) will be testet against UnmarshalException
(no match) and next against Exception (match). So the intended
UnmarshalException will endup in onException(Exception.class).

Why does camel test "from the bottom (nested caused by) and recursive up in
the exception hierarchy"  and not vise versa ... ?


... DRy

-- 
View this message in context: 
http://old.nabble.com/Exception-handling-...-onException-tp26215607p26281107.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to