"The Process Of Combining Related Operations into Single Unit and Execute Them in 'Do Every Thing or Nothing' Manner Called 'Transaction Management'".
Transaction Management have 3 Phases..
- Start Transaction.
- Process Transaction.
- Commit or Rollback Transaction.
NOTE: The Application in which Transaction Management is enabled is known as 'Transactional Component or Transactional App'.
Types of Transactions:
Based on The Number of resources(Database) involved Transactions are Categorized into 2 Types
1. Local Transactions.
2. Global or Distributed Transactions.
If there is only one Resource(Database) Involved in Transaction Then That Transaction is Called Local Transaction.
Ex: Transferring Money Between Same Bank Accounts.
If There are Multiple Types of Resources(Databases) or Number of Same Type Resources(Databases) Involved in Transaction that Transaction is Called Global or Distributed Transaction.
Ex: Transferring Money Between Different Bank Accounts.
Global or Distributed Transaction Works By Using "2PC(2 Phase Commit.)" Protocol,
There are 2 Levels in This Protocol
In 1st level The Distributed Transaction Manager seeks Permission
from the resources(Databases) to commit the Transaction.
In 2nd Level if all the resources gives Permission to Commit then
the Distributed Transaction will be Committed otherwise it will be
rolled back.
The flow of 2PC Protocol
Spring, EJB and Hibernate Supports Local Transactions.
Only Spring and EJB supports Global or Distributed Transactions.
next>>
0 comments:
Post a Comment