Hi

Try with 2.3-SNAPSHOT. I recall some issue with the Spring XML and
<transacted/> with <onException> at route scope.
The Java DSL should work afair.


On Thu, Apr 8, 2010 at 9:07 PM, dnn <[email protected]> wrote:
>
> I am trying to use global onException handling with a transacted route.
> According to the everything I've read, the following should print the "HEY I
> GOT AN EXCEPTION" message:
>
> <camelContext errorHandlerRef="myErrorHandler">
>   <onException>
>      <exception>java.lang.Exception</exception>
>      <log loggingLevel="ERROR" message="HEY I GOT AN EXCEPTION" />
>   </onException>
>   <route>
>      <from uri="jms:test" />
>      <transacted />
>      <to uri="someProcessorThatThrowsAnException" />
>   </route>
> </camelContext>
> <bean id="myErrorHandler"
> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>   <property name="transactionTemplate"
> ref="PROPAGATION_REQUIRES_NEW_TEMPLATE" />
> </bean>
> <bean id="PROPAGATION_REQUIRES_NEW_TEMPLATE"
> class="org.springframework.transaction.support.TransactionTemplate">
>   <property name="transactionManager" ref="transactionManager" />
>   <property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"
> />
> </bean>
>
> I would imagine that when "someProcessorThatThrowsAnException" is executed,
> it will throw an exception that is handled by the global onException
> handler.  However, it doesn't work and my log message is never printed out.
>
> I have found a workaround by moving the onException handling INSIDE the
> <transacted></transacted> block as such:
>
> <camelContext errorHandlerRef="myErrorHandler">
>   <route>
>      <from uri="jms:test" />
>      <transacted>
>         <onException>
>            <exception>java.lang.Exception</exception>
>            <log loggingLevel="ERROR" message="HEY I GOT AN EXCEPTION" />
>         </onException>
>         <to uri="someProcessorThatThrowsAnException" />
>      </transacted>
>   </route>
> </camelContext>
>
> It appears that the <transacted></transacted> block is creating its own
> try/catch block that is ignorant of the global onException handler.  Is this
> the expected behavior?  Is there any way to make it act like my first
> example?  I would prefer using the global onException route to share it
> among several routes.
>
> I am using Camel 2.2.0.
>
> Thanks,
> Dan Nawrocki
>
> --
> View this message in context: 
> http://old.nabble.com/onException-handling-tp28183226p28183226.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to