Transaction Model Resolution
Flat transaction Model: Local transaction and JTA transaction.
Several participants involved in transaction management:
1 explorer (Resource Manager): The resource manager is typically a database management system.
2 Distributed Transaction Coordinator (distributed Transaction COORDINATOR,DTC): This feature is typically implemented by the Java EE Application Server we use, such as jboss,websphere,weblogic. This role only exists in the JTA transaction.
3 transaction manager (Transaction Manager): Each transaction manager is associated with the appropriate resource manager and is responsible for committing or rolling back the distributed transaction.
4 Applications (application)
The relationship of the above four can be expressed by the following figures:
650) this.width=650; "src=" Http://blog.51cto.com/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "style=" border:1px solid RGB (221,221,221); Background-image:url ("/e/u261/lang/zh-cn/images/localimage.png"); background-position:50% 50%;background-repeat:no-repeat; "/>650) this.width=650; src=" https://s1.51cto.com/ Wyfs02/m01/8d/89/wkiol1ihj4sgwj54aafl_-lr6ne553.png "title=" 20140427143812812[1].png "alt=" WKioL1ihJ4SgWj54AAFl_ -lr6ne553.png "/>
In the daily system development, we usually use the data resources (such as database) to save the state of the system, then we divide the transaction into resource-local transaction or JTA Global distributed transaction according to the data resources involved in the system.
1 resource-local Transactions
A resource-local transaction is a transaction that has only one resource management (RM), and the transaction operation operates on the same database.
At this point the transaction is coordinated and the transaction manager's role is implemented by the underlying resource manager. For example, when we use spring to manage transactions, spring does not have a transactional function, it is just a transactional operation that encapsulates the underlying database.
2 Global transaction or JTA transaction
Internationally, a standard OTS (Object Transaction Service) is proposed for a distributed transaction solution, andJava EE implements the OTS, i.e. JTS (Java Transaction Service), for Developers, There is no need to know how they are implemented, because Java provides us with an upper interface JTA (Java Transaction API) for manipulating JTS
Global transactions involve multiple resource managers, which need to be introduced into the transaction Coordinator (which can be understood as a global transaction manager and can be implemented based on reliable messages) for tuning
Communication protocol:
1. The application server communicates with the transaction manager via the TX protocol.
2. The transaction manager communicates with the resource manager through the XA protocol.
3, the transaction manager communicates through the xa+ (XA protocol Superset) protocol.
Submission Process:
Two-phase commit protocol 2PC (phase commit)
First stage: The transaction Coordinator sends a "ready to submit" message to all the transaction managers involved in the transaction, and then it distributes the message to the appropriate resource manager, and the transaction manager then informs the Distributed Transaction Coordinator (DTC) of the resource management response. Only after this phase has completed successfully (both the Resource Manager agrees to commit the transaction) will it enter the second phase.
Second stage: When the first phase is completed successfully, the transaction coordinator tells the transaction manager to commit the transaction
Distributed final consistency theory:
CAP
C (consistency) in distributed environment, the data of multiple nodes is consistent;
A (availability) service has been kept in a usable state;
P (partition tolerance) in distributed applications, it may be because of some distributed causes the system can not function, good partition tolerance, so that the application is a distributed system, but it seems to be a normal operation of the whole
BASE
Ba:basic availability basic business availability;
S:soft state flexibility;
E:eventual consistency final consistency;
This article is from the "talking About Technology" blog, please be sure to keep this source http://netpeak.blog.51cto.com/1135737/1939106
Analysis of database Transaction model