What is Transaction Management?
Transaction management refers to the ability to manage the flow and consistency of data across multiple systems or services involved in an organization. It ensures that all operations within a transaction are executed as a single unit, where either all operations are successful or none of them are executed.
This guarantees data integrity and reliability, preventing inconsistencies or data corruption.
MuleSoft provides strong transaction management features for - database operations, web service invocations, or message queuing systems (VM, JMS).
Transaction Types
Local Transactions
Local transactions are known as single resource transactions operates on a single type of resources (JDBC, JMS) and it doesn’t support nested transactions.
Eg: If you develop an application that connects to only one specific database and all grouped operations which are part of that single unit use same JDBC connection, then you can use Local Transaction management
XA Transactions (Extended Architecture) are known as global transactions which use two Phase Commit (2PC) protocol for managing transactions. XA transactions are used, when you deal with transactions spanning across multiple systems with separate connections and it supports nested transactions.
Transactional Actions
Transactional Action (transactionalAction) defines the type of action that operations take regarding transactions.
- ALWAYS_BEGIN
- ALWAYS_JOIN
- BEGIN_OR_JOIN
- JOIN_IF_POSSIBLE
- INDIFFERENT
- NONE
- NOT_SUPPORTED
Event Source: We can configure in event source like VM Listener, JMS etc.
Go to Advanced Tab: set Transaction Type and Transactional action.
Try Scope: Open the Try scope - General Tab and set Transaction Type and Transactional action.
How Transactions Affect the Scopes?
Async:
When running within a transaction, it will run in another thread (asychronous). Which means, all the processors within the scope are out of transactional scope. If any error produced inside an Async scope will not rollback.
Parallel ForEach: It will not execute in parallel. Works as a simple ForEach. This does not affect the way this scope handle the errors
Batch Processing: It works as parallel and the batch execution is not part of the transaction
Scatter-Gather: It will not execute in parallel.
Source Code: Import it in your local studio and make changes as per your DB connection and DB table.
Source: MuleSoft Documentation.
Thanks for reading :-)
No comments:
Post a Comment