camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" <claus.ib...@gmail.com>
Subject Re: Will onException handle exceptions thrown from 'when' clause?
Date Tue, 16 Dec 2008 13:56:46 GMT
Hi

I was curious why your choice route does not continue to some other
destination if the when is true.
If beanTwo returns true then the exchange should be routed to ... void????
And when beanTwo returns false the exchange is routed to the otherwise block.

But nevertheless the exception should be caught by onException.

Remember to document on the JIRA which version of Camel you are using.


   <choice>
                               <when>
                                       <methodCall bean="beanTwo"
method="methodFromBeanTwo"/>
                               </when>
                               <otherwise>
                                       <to
uri="bean:beanOne?methodName=methodFromBeanOne" />
                               </otherwise>
                       </choice>


On Tue, Dec 16, 2008 at 2:26 PM, Fush <rikard.eriksen@gmail.com> wrote:
>
> Hi!
> See the route below. beanOne throws ExceptionOneException and beanTwo throws
> ExceptionTwoException. It seems that the only exception that is actually
> being caught and handled by an onException clause, is the
> ExceptionOneException. The ExceptionTwoException goes all the way through,
> without being caught and routet to the exceptionTwoQueue as it's supposed
> to. Can anyone here confirm this behavior? And is it supposed to work like
> that?
>
>        <camelContext id="MyCamelContext
> xmlns="http://activemq.apache.org/camel/schema/spring">
>                <endpoint id="myMainQueue" uri="activemq:${my.project.queue.main}"/>
>                <endpoint id="exceptionOneQueue"
> uri="activemq:${my.project.queue.exceptionOne}"/>
>                <endpoint id="exceptionTwoQueue"
> uri="activemq:${my.project.queue.exceptionTwo}"/>
>                <route>
>                        <from ref="myMainQueue" />
>                        <onException>
>                                <exception>my.project.queue.ExceptionOneException</exception>
>                                <redeliveryPolicy maximumRedeliveries="0" />
>                                <handled>
>                                        <constant>true</constant>
>                                </handled>
>                                <to ref="exceptionOneQueue"/>
>                        </onException>
>                        <onException>
>                                <exception>my.project.queue.ExceptionTwoException</exception>
>                                <redeliveryPolicy maximumRedeliveries="0" />
>                                <handled>
>                                        <constant>true</constant>
>                                </handled>
>                                <to ref="exceptionTwoQueue"/>
>                        </onException>
>                        <onException>
>                                <exception>java.lang.Exception</exception>
>                                <redeliveryPolicy maximumRedeliveries="0" />
>                                <handled>
>                                        <constant>false</constant>
>                                </handled>
>                        </onException>
>                        <unmarshal>
>                                <jaxb prettyPrint="true" contextPath="my.project.domain"
/>
>                        </unmarshal>
>                        <choice>
>                                <when>
>                                        <methodCall bean="beanTwo" method="methodFromBeanTwo"/>
>                                </when>
>                                <otherwise>
>                                        <to uri="bean:beanOne?methodName=methodFromBeanOne"
/>
>                                </otherwise>
>                        </choice>
>                </route>
> </camelContext>
> --
> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21033017.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Mime
View raw message