You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Frank <fd...@gmail.com> on 2012/03/01 05:41:18 UTC

Dynamic router EIP and Eceptions

Hi, 
I am using Dynamic pattern EIP to perform loop for 10 iterations. If an
exception occurred in fourth iteration, then I caught that exception using
onException clause or doTry()…doCatch(). Is that possible I can print the
error message and continue with the other iterations? If so, please tell me
how. Please help me. I appreciate all of your help.
http://camel.465427.n5.nabble.com/Iterating-beans-in-the-route-td5494610.html

--Frank


--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-router-EIP-and-Eceptions-tp5526894p5526894.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic router EIP and Eceptions

Posted by Babak Vahdat <ba...@swissonline.ch>.
I don't get exactly your point!

Using the loop() DSL if at the iteration N an exception is thrown then that
iteration is already bail out because of the onException clause being
running and as you do continued(true) at the end of onException() then you
would continue on the iteration N+1.

And regarding the exception you mentioned: While running on the onException
clause it seems there is still *another* exception being caused there, so
why FatalFallbackErrorHandler being triggered here, like when you would do
catch in Java and cause another exception inside the catch block while
processing the original catched exception. Please send the whole log as
there's should be lines like:


\\--> Previous exception on exchangeId: .... 
...
\\--> New exception on exchangeId: ....
...

Maybe also provide your complete Camel route(s) here so I can get your
point. And what version of Camel do you use?

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-router-EIP-and-Eceptions-tp5526894p5528455.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic router EIP and Eceptions

Posted by Frank <fd...@gmail.com>.
Thank you Mr. Vahdat. Your suggestions are very helpful. But, I do not want
to continue further in that particular iteration after the exception has
occurred. (In other words, bail out when the exception occurred in the
iteration and continue with other iterations.) 
Second question: I am unable to re-throw the same/new exception. I am
getting the below error.

ERROR FatalFallbackErrorHandler:53 - Exception occurred while trying to
handle previously thrown exception on exchangeId:
ID-FRANKDREW-PC-50273-1330618179143-0-1 using

Is there any possibility I can re-throw the same/new exception? Please help
me. 

Thanks, 
Frank

--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-router-EIP-and-Eceptions-tp5526894p5528310.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic router EIP and Eceptions

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

Yes, using the onException clause you could make use of continued(true).
Also take a look at [1] for the semantics of "handled" & "continued" DSL
elements.

One possible way would be:

                onException(MyIgnoredException.class).process(new
Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception
{
                       Exception exception =
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);                       
                       String message = exception.getMessage();
                      
                      // now do whatever you want with the exception
message...
                    }
                }).continued(true);


[1] http://camel.apache.org/exception-clause.html

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-router-EIP-and-Eceptions-tp5526894p5527400.html
Sent from the Camel - Users mailing list archive at Nabble.com.