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.

Reply via email to