Does the exception-pattern attribute on the commit-transaction tag work? That is, in a default exception strategy I can get this to work,
<commit-transaction exception-pattern="*"/>
but not this:
<commit-transaction exception-pattern="some.specific.Exception"/>
Here is a relevant snippet of the configuration:
<mule ...>
<jms:activemq-connector name="JMSConnector" brokerURL="${messaging.brokerURL}" />
<flow name="aFlow">
<jms:inbound-endpoint name="endpoint.Name" queue="${queue}"
exchange-pattern="request-response"
connector-ref="JMSConnector" />
<component>
<spring-object bean="ThrowsBusinessException" />
</component>
<default-exception-strategy>
<commit-transaction exception-pattern="com.BusinessException" />
</default-exception-strategy>
</flow>
</mule>
If I use exception-pattern="*", the JMS message is not re-delivered. However, if I use the more specific exception-pattern, the message is re-delivered. I don’t want the message to be re-delivered if the exception thrown is BusinessException.
This is in Mule CE 3.2.1
Thanks!
The core issue is the following: all exceptions thrown by a component are wrapped in a
org.mule.component.ComponentException.default-exception-strategyused to but now fails to unwrap this exception to its root cause, which means theexception-patterngets applied to theorg.mule.component.ComponentException.IMO this is a bug in Mule. I’ve opened MULE-6218. Please vote for/watch it.
In the meantime, you can create a custom exception strategy that unwraps the Mule exceptions before to handling them. For this, use:
ExceptionHelper.getRootException(ex)