Transaction demarcation documentation
Transaction demarcation provides the ability to execute a group of message processors within the same transaction. To use it just place all the transactional message processors inside a transactional element.
Mule will auto-discover the type of the transaction (jms, jdbc, vm) by creating the transaction for the first transactional resource encountered
Using more than one type of transactional element inside transactional
If more than one type of transactional resource is present in the transactional element it will fail.
To be able to use another type of transactional element NOT_SUPPORTED action type must be used.
Mule EE supports transaction demarcation for multi transactional resources. It support XA transactions and Multi transactions
How to join a transaction an existent transaction
With transaction demarcation there's two possible transaction actions:
- ALWAYS_BEGIN: This is the default action. Mule will always begin a transaction if there's no action configured or action is ALWAYS_BEGIN.
- BEGIN_OR_JOIN: In this case, if there's a transaction in context, mule will try to join it, but if there's no transaction, transactional element will create one.
Error handling with transactional element
Transaction demarcation will start a transaction and end it, no matter the result. So, to make it work properly will must handle any exception thrown within the transactional scope. To do that transactional element has its own exception strategy.
If no exception strategy is configured then the default one will be applied. See how to define the default exception strategy