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

Single Resource Transactions

Use a Single Resource transaction (also known as a simple transaction or local transaction) to send or receive messages using only one single resource: JMS, VM, or JDBC. The example below illustrates a flow which includes a single resource transaction applied to inbound and outbound JMS connectors. 

<flow name="testFlow1" doc:name="testFlow1">
        <jms:inbound-endpoint queue="" connector-ref="JMS" doc:name="JMS">
            <jms:transaction action="ALWAYS_BEGIN"/>
        <jms:outbound-endpoint doc:name="JMS" connector-ref="JMS" queue="test.out">
            <jms:transaction action="ALWAYS_JOIN"/>

The configuration above defines a JMS connector that receives on a "" queue and another JMS connector that sends on a "test.out" queue. The action attribute dictates how Mule initiates a transaction. Within this flow, Mule starts a new transaction for every message it receives (inbound connector), and always joins a transaction in progress for every message it sends (outbound connector).  Mule commits only those messages which successfully pass through the complete flow; if at any point in the flow a message throws an exception, Mule rolls back the transaction.

This is a single resource transaction because both JMS connectors are referencing the same JMS global element.
You can join multiple endpoints on a same transaction only if they all refer the same element.

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