camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Goyal, Arpit" <arpit.go...@sap.com>
Subject RE: Try-Catch in choice-when
Date Wed, 13 Nov 2013 13:15:17 GMT
Any idea how can I achieve the following?

-----Original Message-----
From: Goyal, Arpit [mailto:arpit.goyal@sap.com] 
Sent: Wednesday, November 13, 2013 9:42 AM
To: users@camel.apache.org
Subject: Try-Catch in choice-when

Hi All,

I am trying to use Try-Catch inside 'when' but not sure how to get it right. I am using BLUEPRINT
DSL. Following is my route:

<camel:route>
<camel:from ref="Sender"/>

<camel:setHeader headerName="MyHeader">
<camel:constant>GOOD</camel:constant>
</camel:setHeader>

<camel:choice>
<camel:when>
<camel:doTry>
<camel:xpath>//MessageId = 'a'</camel:xpath>
<camel:to ref="Receiver1"/>
<camel:doCatch>
                                                                <camel:exception>org.apache.camel.builder.xml.InvalidXPathExpression</camel:exception>
                                                                <camel:to uri="log:TryCatchEval?level=INFO"/>
</camel:doCatch>
</camel:doTry>
</camel:when>
<camel:when>
<camel:simple>${header.MyHeader} == 'GOOD'</camel:simple>
<camel:to ref="Receiver_"/>
</camel:when>
<camel:otherwise/>
</camel:choice>
</camel:route>

Here the prefix camel stands for xmlns:camel=http://camel.apache.org/schema/blueprint

Basically the idea which we want to achieve is, in case my first condition fails (due to some
exception), I want to execute the second condition and have hard restriction that I can't
change my pattern of choice-when.

As per the camel-blueprint xsd (http://camel.apache.org/schema/blueprint/camel-blueprint-2.11.2.xsd),
whenDefinition expects first element to be some language element and then allows Try-Catch.
What if the language it-self throws exception? How can I prevent that?

Regards,
Arpit.

Mime
View raw message