Tuesday, November 1, 2016

Mule VM Transactions Not Rolling Back

I had a flow containing this endpoint:

<vm:inbound-endpoint exchange-pattern="one-way" address="vm://ABC">
<idempotent-redelivery-policy useSecureHash="false" idExpression="#[message.id]" />
<vm:transaction action="ALWAYS_BEGIN"/>
</vm:inbound-endpoint>

And a standard Rollback Exception Strategy with maxRedeliveryAttempts set to 0.

When an exception was thrown in the flow, the Rollback Exception Strategy was hit but the redelivery exhausted block was never hit because the message was never rolled back.

The problem was that the message was sent to the inbound endpoint synchronously (MuleClient.send). This wont work because the inbound endpoint is one-way.  When the message was sent asynchronously (MuleClient.dispatch), the message was rolled back.