Contact Us 1-800-596-4880

Multiple Resource Transactions

Use a Multi Resource transaction to group a series of operations from multiple JMS or VM resources into a single virtual transaction.

Multiple resource transactions are useful for creating transactional bridges without employing distributed transactions. For example, if you want to bridge two different connectors to form a transactional unit you could configure the multiple resource transaction as per the example below:

<mule xmlns:wmq="" xmlns:ee="" xmlns:jms="" xmlns="" xmlns:doc="" xmlns:spring=""  xmlns:xsi="" xsi:schemaLocation="">

    <jms:activemq-connector name="jmsConnector"

    <wmq:connector name="wmqConnector"

    <flow name="MultiTxFlow">
        <jms:inbound-endpoint queue="in" connector-ref="jmsConnector">
            <ee:multi-transaction action="ALWAYS_BEGIN"/>
        <wmq:outbound-endpoint queue="out" connector-ref="wmqConnector">
             <ee:multi-transaction action="ALWAYS_JOIN"/>

In this example, Mule starts the local JMS transaction when it receives the message on the inbound endpoint. Mule starts the local WMQ transaction when it sends the message out on the outbound endpoint. In this case, because the connectors are configured as multiple resource transactions, Mule commits the WMQ transaction first, then commits the JMS transaction.
Ultimately, Mule either commits both transactions successfully or fails and rolls back both of them as one virtual unit.

Consider that grouping connector operations into one multiple resource transaction implies a tradeoff between low overhead and reliability.
Although multiple resource transactions are intended to have less overhead than XA transactions, under certain circumstances (e.g. one of the brokers crashing while commit/rollbacks are performed), an unacknowledged message could be redelivered later, causing duplicate data processing if not handled properly. You might even have to handle these duplicates manually.
If reliability is your main concern, you should always use XA transactions.

Note that if you configure an inbound connector with a multiple resource transaction, you must also configure any other connectors as multiple resource transactions and the action set to "ALWAYS_JOIN" to become part of the virtual transaction unit.

Refer to Transaction Management for details on how to configure a Multiple Resource transaction.