0
votes

I have a Mule flow where I configured a multi-resource transaction with transactional scope and rollback exception strategy to roll back an exception and redelivery the message to start the transaction again. But the rollback exception strategy doesn't redeliver the message. Below is the flow config.

<ee:multi-transactional action="ALWAYS_BEGIN" doc:name="Transactional">
    <db:insert config-ref="MySQL_Configuration" autoGeneratedKeys="true" autoGeneratedKeysColumnIndexes="1" autoGeneratedKeysColumnNames="generated_key"
    doc:name="Database" transactionalAction="ALWAYS_JOIN">
        <db:parameterized-query>
            <![CDATA[INSERT INTO DEMO(NAME, AGE) VALUES(#[payload.customer.name],#[payload.customer.age])]]>
        </db:parameterized-query>
    </db:insert>
    <component class="org.ram.BusinessComponent" doc:name="Throw Exception" />
    <jms:outbound-endpoint queue="${queue.name}" connector-ref="Active_MQ" doc:name="JMS">
        <ee:multi-transaction action="ALWAYS_JOIN" />
    </jms:outbound-endpoint>
    <rollback-exception-strategy doc:name="Rollback Exception Strategy" maxRedeliveryAttempts="3">
        <logger doc:name="Logger" />
        <on-redelivery-attempts-exceeded>
            <logger level="INFO" doc:name="Logger"/>
        </on-redelivery-attempts-exceeded>
    </rollback-exception-strategy>
</ee:multi-transactional>

Can anyone please solve the issue?

1

1 Answers

1
votes

Is the code you shared your complete flow? You are planning to do an insert in the DB with some values. So the transactional scope should be part of a flow. The transactional scope will make sure that the operations that are in the scope will all succeed or will all fail.

So in your case the DB insert goes OK, error occurs, message can't be put on JMS queue so the DB insert operation is being rolled back, that means isn't committed.

Like the docs say: In this type of scenario, the commit is either entirely complete and succeeds, or is incomplete and it fails. Even if partially complete, the commit – or transaction – fails. Where a transaction fails, Mule rolls back the operations within the transaction so that no one part results in partial completion.

If you want redelivery the message should be kept somewhere, try using VM queues and use them as a 'buffer'.

Have a look at these two examples: https://www.mulesoft.com/exchange#!/using-transactional-scope-in-jms-to-database

https://www.mulesoft.com/exchange#!/jms-message-rollback-redelivery