You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kcostilow <kc...@accelarad.com> on 2011/08/22 20:51:16 UTC

Multicast Aggregation Exception Handling

I'm trying to catch exceptions in each of my multicast processors, log it,
and continue on.

I've learned from this forum that onException() is not the way to go,
because it applies to the entire route and not just to the multicast
portion, fine.

So from the camel docs I discovered I could implement my own
AggregationStrategy and pick up any Exceptions there.

This worked when one exception occurred, but, not when 2 processors in a
single multicast both throw an exception.

See attached unit test. 
http://camel.465427.n5.nabble.com/file/n4724273/TestMulticastExceptionHandling.java
TestMulticastExceptionHandling.java 

Note also that I've tried wrapping each multicasted processor in its own
doTry()...doCatch() container, but, when I do that, I cannot get access to
the exception, getProperty(Exchange.EXCEPTION_CAUGHT) shows empty (I can add
a unit test for this and re-post if proof is needed).

1. Am I doing this right?
2. If this is a bug, are there any ideas for a workaround?

Camel 2.8.0

--
View this message in context: http://camel.465427.n5.nabble.com/Multicast-Aggregation-Exception-Handling-tp4724273p4724273.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Multicast Aggregation Exception Handling

Posted by kcostilow <kc...@accelarad.com>.
Answering my own question #2, because I found a workaround:

Setting exception to null in aggreate() passes the unit test:

        public Exchange aggregate(Exchange oldExchange, Exchange
newExchange) {
            Throwable t = newExchange.getProperty(Exchange.EXCEPTION_CAUGHT,
Throwable.class);
            if (t != null) {
                System.err.println(t);
                exceptions.add(t);
                
                newExchange.setException(null);
            }

            return newExchange;
        }     



--
View this message in context: http://camel.465427.n5.nabble.com/Multicast-Aggregation-Exception-Handling-tp4724273p4724338.html
Sent from the Camel - Users mailing list archive at Nabble.com.