Hi all,
      I am a newbie to Camel and recently I've been stuck in this problem(I
am using Camel with Spring):
      I defined an errorHandler in the CamelContext tag and I want it to be
applied to all of my routes. In one of my route, I use <camel: when> and
inside of that I bind a method in a POJO as the predicate. The problem is
that when the method throws an exception, it is not handle by the
errorHandler, instead, the exception is added to the exchange and the route
continues. 
      Example code:
      <camel:camelContext id="context" errorHandlerRef="myHandler">
           <camel:route id="myRoute">
               <camel:choice>
                   <camel:when>
                       <camel:method beanType="MyClass"
method="myMethodThatThrowsException"/>
                           do something... 
                   </camel:when>
                   <camel:otherwise>
                       do something else...
                   </camel:otherwise>
               </camel:choice>       
           </camel:route>

           other routes...
      </camel:camelContext>  

      <bean id="myHandler"
class="org.apache.camel.builder.DeadLetterChannelBuilder">
          <proeprty name="redeliveryPolicy" ref="myPolicy" />
          <property name="onRedelivery" ref="myAlert" /> 
          <property name="deadLetterUri" value="mock:dead" />      
      </bean>

      <bean id="myPolicy">
       ...
      </bean>
     
      <bean id="myAlert">
       ...
      </bean>  

       Is there a way that I can handle the exception thrown by
"myMethodThatThrowsException" using "myHandler"? 
       Please let me know if I missed anything. Any suggestion is
appreciated!  

Best
Yiming

-- 
View this message in context: 
http://camel.465427.n5.nabble.com/how-to-handle-exceptions-thrown-by-camel-choice-tp3245484p3245484.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to