You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Fush <ri...@gmail.com> on 2008/12/16 14:26:11 UTC

Will onException handle exceptions thrown from 'when' clause?

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.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

On Tue, Dec 16, 2008 at 2:43 PM, Fush <ri...@gmail.com> wrote:
>
> It seems that the XML is not valid if the <from> tag is not immediately after
> the <route> tag. So I'm not allowed to move the <onException> tags to the
> top. I'll create a Jira issue as you suggested.
In the Java DSL you can do this, so I was hoping it would help. Yeap
create the JIRA and let me take a look.

Maybe as a work around you can have some kind of dummy route before
the choice, i.e. shoot in a processor, or another bean that does not
fail. Just to verify that if the choice .. otherwise combo is not
directly after the from.

from(xxx).to("bean:diummy").choice ....







>
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> No it's not supposed to work like that.
>> Could you move the onException before the from clause?
>>
>> So its like this
>>>                <route>
>>>                        <onException>
>> ...
>>>                        <from ref="myMainQueue" />
>>
>> And try it. It could be a difference if the onException is defined
>> outside the from.
>>
>> I think I need to take a look to see what happens when you have the
>> choice .. otherwise. There could be a flaw there.
>>
>> Could you create a ticket in JIRA with this issue?
>> http://activemq.apache.org/camel/support.html
>> there is a link from the support page
>>
>
> --
> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21033324.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

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

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Fush <ri...@gmail.com>.
It seems that the XML is not valid if the <from> tag is not immediately after
the <route> tag. So I'm not allowed to move the <onException> tags to the
top. I'll create a Jira issue as you suggested.



Claus Ibsen-2 wrote:
> 
> Hi
> 
> No it's not supposed to work like that.
> Could you move the onException before the from clause?
> 
> So its like this
>>                <route>
>>                        <onException>
> ...
>>                        <from ref="myMainQueue" />
> 
> And try it. It could be a difference if the onException is defined
> outside the from.
> 
> I think I need to take a look to see what happens when you have the
> choice .. otherwise. There could be a flaw there.
> 
> Could you create a ticket in JIRA with this issue?
> http://activemq.apache.org/camel/support.html
> there is a link from the support page
> 

-- 
View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21033324.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

No it's not supposed to work like that.
Could you move the onException before the from clause?

So its like this
>                <route>
>                        <onException>
...
>                        <from ref="myMainQueue" />

And try it. It could be a difference if the onException is defined
outside the from.

I think I need to take a look to see what happens when you have the
choice .. otherwise. There could be a flaw there.

Could you create a ticket in JIRA with this issue?
http://activemq.apache.org/camel/support.html
there is a link from the support page



On Tue, Dec 16, 2008 at 2:26 PM, Fush <ri...@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/

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Fush <ri...@gmail.com>.
OK. When is 1.5.1 scheduled for release?


Claus Ibsen-2 wrote:
> 
> Hi
> 
> See the JIRA comments. It's fixed in Camel 1.5.1.
> 
> The issue manifests itself when you use beans for predicates and they
> throw exception. If you use other kind of predicates then it should be
> okay. However it's fixed in 1.5.1
> 

-- 
View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21048943.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by "S. Ali Tokmen" <sa...@bull.net>.
Hello Claus

Thank you for these excellent news!

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com



Claus Ibsen a écrit :
> On Wed, Jan 28, 2009 at 2:14 PM, Fush <ri...@gmail.com> wrote:
>   
>> Claus, do you know if there's a Camel patch for this issue? We will be
>> looking into FUSE in the future, but we have the need for a quick fix for
>> this now.
>>     
> It should be fixed in the FUSE camel version 1.5.3.0
>
> http://repo.fusesource.com/maven2/org/apache/camel/camel-core/1.5.3.0-fuse/
>
> Maven repo:
> http://repo.fusesource.com/maven2
>
> Basically just use this version for camel: 1.5.3.0-fuse
> And use the maven repo link from above:
>
>
> Its Hadrian that does the Apache Camel releases, and we need the dusts
> from the transition to Camel TLP to settle.
> But I guess Camel 1.6.0 could be GA within 2 weeks time.
>
>
>   
>> Claus Ibsen-2 wrote:
>>     
>>> On Wed, Dec 17, 2008 at 9:26 AM, Fush <ri...@gmail.com> wrote:
>>>       
>>>> Oh, and in the Jira issue, you suggested I use the 1.5.1-SNAPSHOT
>>>> version.
>>>> But the repo for it looks rather empty:
>>>> http://people.apache.org/repo/m2-snapshot-repository/org/apache/camel/apache-camel/1.5-SNAPSHOT/
>>>>         
>>> Yeah Willem Jiang have noticed this as well. Something must have gone
>>> wrong when we branched for 1.x and trunk.
>>>
>>> There is a thread somewhere on the camel-dev for discussing when the
>>> 1.5.1 release should be build.
>>> Usually it's Hadrian that does the build and cut the release candidates.
>>>
>>> I was hoping we could make a release before x-mas or at the end of
>>> this year. But feel free to find this thread and pick up the
>>> discussion so we get some attention to this one. We have some good and
>>> important fixes in there.
>>>
>>>
>>>
>>>       
>>>> Claus Ibsen-2 wrote:
>>>>         
>>>>> Hi
>>>>>
>>>>> See the JIRA comments. It's fixed in Camel 1.5.1.
>>>>>
>>>>>           
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21049013.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>>         
>>>
>>> --
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>>       
>> --
>> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21705454.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>     
>
>
>
>   


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jan 28, 2009 at 2:14 PM, Fush <ri...@gmail.com> wrote:
>
> Claus, do you know if there's a Camel patch for this issue? We will be
> looking into FUSE in the future, but we have the need for a quick fix for
> this now.
It should be fixed in the FUSE camel version 1.5.3.0

http://repo.fusesource.com/maven2/org/apache/camel/camel-core/1.5.3.0-fuse/

Maven repo:
http://repo.fusesource.com/maven2

Basically just use this version for camel: 1.5.3.0-fuse
And use the maven repo link from above:


Its Hadrian that does the Apache Camel releases, and we need the dusts
from the transition to Camel TLP to settle.
But I guess Camel 1.6.0 could be GA within 2 weeks time.


>
>
> Claus Ibsen-2 wrote:
>>
>> On Wed, Dec 17, 2008 at 9:26 AM, Fush <ri...@gmail.com> wrote:
>>>
>>> Oh, and in the Jira issue, you suggested I use the 1.5.1-SNAPSHOT
>>> version.
>>> But the repo for it looks rather empty:
>>> http://people.apache.org/repo/m2-snapshot-repository/org/apache/camel/apache-camel/1.5-SNAPSHOT/
>> Yeah Willem Jiang have noticed this as well. Something must have gone
>> wrong when we branched for 1.x and trunk.
>>
>> There is a thread somewhere on the camel-dev for discussing when the
>> 1.5.1 release should be build.
>> Usually it's Hadrian that does the build and cut the release candidates.
>>
>> I was hoping we could make a release before x-mas or at the end of
>> this year. But feel free to find this thread and pick up the
>> discussion so we get some attention to this one. We have some good and
>> important fixes in there.
>>
>>
>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> See the JIRA comments. It's fixed in Camel 1.5.1.
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21049013.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21705454.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Fush <ri...@gmail.com>.
Claus, do you know if there's a Camel patch for this issue? We will be
looking into FUSE in the future, but we have the need for a quick fix for
this now.


Claus Ibsen-2 wrote:
> 
> On Wed, Dec 17, 2008 at 9:26 AM, Fush <ri...@gmail.com> wrote:
>>
>> Oh, and in the Jira issue, you suggested I use the 1.5.1-SNAPSHOT
>> version.
>> But the repo for it looks rather empty:
>> http://people.apache.org/repo/m2-snapshot-repository/org/apache/camel/apache-camel/1.5-SNAPSHOT/
> Yeah Willem Jiang have noticed this as well. Something must have gone
> wrong when we branched for 1.x and trunk.
> 
> There is a thread somewhere on the camel-dev for discussing when the
> 1.5.1 release should be build.
> Usually it's Hadrian that does the build and cut the release candidates.
> 
> I was hoping we could make a release before x-mas or at the end of
> this year. But feel free to find this thread and pick up the
> discussion so we get some attention to this one. We have some good and
> important fixes in there.
> 
> 
> 
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> See the JIRA comments. It's fixed in Camel 1.5.1.
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21049013.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21705454.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Dec 17, 2008 at 9:26 AM, Fush <ri...@gmail.com> wrote:
>
> Oh, and in the Jira issue, you suggested I use the 1.5.1-SNAPSHOT version.
> But the repo for it looks rather empty:
> http://people.apache.org/repo/m2-snapshot-repository/org/apache/camel/apache-camel/1.5-SNAPSHOT/
Yeah Willem Jiang have noticed this as well. Something must have gone
wrong when we branched for 1.x and trunk.

There is a thread somewhere on the camel-dev for discussing when the
1.5.1 release should be build.
Usually it's Hadrian that does the build and cut the release candidates.

I was hoping we could make a release before x-mas or at the end of
this year. But feel free to find this thread and pick up the
discussion so we get some attention to this one. We have some good and
important fixes in there.



>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> See the JIRA comments. It's fixed in Camel 1.5.1.
>>
>
> --
> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21049013.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

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

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Fush <ri...@gmail.com>.
Oh, and in the Jira issue, you suggested I use the 1.5.1-SNAPSHOT version.
But the repo for it looks rather empty:
http://people.apache.org/repo/m2-snapshot-repository/org/apache/camel/apache-camel/1.5-SNAPSHOT/


Claus Ibsen-2 wrote:
> 
> Hi
> 
> See the JIRA comments. It's fixed in Camel 1.5.1.
> 

-- 
View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21049013.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See the JIRA comments. It's fixed in Camel 1.5.1.

The issue manifests itself when you use beans for predicates and they
throw exception. If you use other kind of predicates then it should be
okay. However it's fixed in 1.5.1

On Tue, Dec 16, 2008 at 7:10 PM, Claus Ibsen <cl...@gmail.com> wrote:
> How are the two exceptions related? Do one extend the other or are
> their exception hierarchy totally separated?
>
>
> On Tue, Dec 16, 2008 at 4:17 PM, Fush <ri...@gmail.com> wrote:
>>
>> Anyway, using <filter> still doesn't cause the exception to be caught. Here
>> the Jira for it:  https://issues.apache.org/activemq/browse/CAMEL-1188
>> Camel-1188 .
>> --
>> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21034979.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



-- 

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

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
How are the two exceptions related? Do one extend the other or are
their exception hierarchy totally separated?


On Tue, Dec 16, 2008 at 4:17 PM, Fush <ri...@gmail.com> wrote:
>
> Anyway, using <filter> still doesn't cause the exception to be caught. Here
> the Jira for it:  https://issues.apache.org/activemq/browse/CAMEL-1188
> Camel-1188 .
> --
> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21034979.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

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

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Fush <ri...@gmail.com>.
Anyway, using <filter> still doesn't cause the exception to be caught. Here
the Jira for it:  https://issues.apache.org/activemq/browse/CAMEL-1188
Camel-1188 .
-- 
View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21034979.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Dec 16, 2008 at 4:04 PM, Fush <ri...@gmail.com> wrote:
>
> I'll try the filter. But I want my messages to be dropped if the predicate is
> true. If beanTwo returns false, only then should the route continue. Is that
> possible to express in the current DSL, or would I have to alter the method
> called?
Yeah you can probably use a predicate something like this:

      <filter>
        <predicate>
          <methodCall ..../>
          <isEqualTo value="false"/>
        </predicate>
     </filter>

Using the predicate you have the usual equal, not equal, null, not
null, regexp etc. to test with.


>
>
> Claus Ibsen-2 wrote:
>>
>> On Tue, Dec 16, 2008 at 3:16 PM, Fush <ri...@gmail.com> wrote:
>> Yeah its more like the filter EIP and maybe this one works ;)
>> http://activemq.apache.org/camel/message-filter.html
>>
>> Any messages which the filter predicate returns false will be dropped.
>>
>
> --
> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21034693.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

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

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Fush <ri...@gmail.com>.
I'll try the filter. But I want my messages to be dropped if the predicate is
true. If beanTwo returns false, only then should the route continue. Is that
possible to express in the current DSL, or would I have to alter the method
called?


Claus Ibsen-2 wrote:
> 
> On Tue, Dec 16, 2008 at 3:16 PM, Fush <ri...@gmail.com> wrote:
> Yeah its more like the filter EIP and maybe this one works ;)
> http://activemq.apache.org/camel/message-filter.html
> 
> Any messages which the filter predicate returns false will be dropped.
> 

-- 
View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21034693.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Dec 16, 2008 at 3:16 PM, Fush <ri...@gmail.com> wrote:
>
> Only if the result from beanTwo is false, should the message be routed on to
> beanOne. If beanTwo returns true, no further action is to be taken, and the
> route ends there. Would you recommend some other way of configuring such a
> route?
Yeah its more like the filter EIP and maybe this one works ;)
http://activemq.apache.org/camel/message-filter.html

Any messages which the filter predicate returns false will be dropped.

>
>
> Claus Ibsen-2 wrote:
>>
>> 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>
>>
>
> --
> View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21033855.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

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

Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Fush <ri...@gmail.com>.
Only if the result from beanTwo is false, should the message be routed on to
beanOne. If beanTwo returns true, no further action is to be taken, and the
route ends there. Would you recommend some other way of configuring such a
route?


Claus Ibsen-2 wrote:
> 
> 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>
> 

-- 
View this message in context: http://www.nabble.com/Will-onException-handle-exceptions-thrown-from-%27when%27-clause--tp21033017s22882p21033855.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Will onException handle exceptions thrown from 'when' clause?

Posted by Claus Ibsen <cl...@gmail.com>.
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 <ri...@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/