Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Multiple Resource Transactions

Use a Multi Resource transaction to group together 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.


       
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<mule xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd

http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd

http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd

http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd

http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd">

    <jms:activemq-connector name="jmsConnector"
                            maxRedelivery="3"
                            disableTemporaryReplyToDestinations="true"/>

    <wmq:connector name="wmqConnector"
                   hostName="winter"
                   port="1414"
                   disableReplyToHandler="true"
                   disableTemporaryReplyToDestinations="true"
                   queueManager="MY_QUEUE_MANAGER"
                   targetClient="NONJMS_MQ"
                   transportType="CLIENT_MQ_TCPIP"
                   specification="1.1"
                   numberOfConsumers="16"
                   username=""
                   password=""/>

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

In the example above, Mule starts the local JMS transaction when it receives the message on the inbound connector. Mule starts the local WMQ transaction when it sends the message out on the outbound connector. 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.  

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.