Distributed Transaction principle explore (a)

Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link! https://blog.csdn.net/Little_fxc/article/details/87269703

Distributed Transaction principle explore (a)

The concept combing

First of all, I am in the process of learning a distributed transaction, we met many of the concepts, such as: X / Open XA, two-phase commit (2PC), JTA and so on.
Concept a bit more, we need to sort out the record.

X/Open XA

(Excerpt from Wikipedia ) in computing technology,
XA specification is open specifications for the group distributed transaction processing (DTP) is.
Specification describes the interface between the global transaction manager to the local resource manager.
XA specification object is to allow a plurality of resources (e.g., databases, application servers, message queue, etc.)
accessed by the same transaction, so that the ACID properties can be made and remain valid across applications.
XA two-phase commit to ensure that all resources are committed or rolled back any specific transaction.
XA specification describes the resource manager to support transactional access necessary things to do.
Comply with the specification of the resource manager is called XA compliant.

DTP

DTP (full name Distributed Transaction Processing Reference Model), is a norm,
he defines some behavior between objects and object model to guide distributed transactions between these objects and object behavior to achieve.

Here Insert Picture Description

From the above chart shows, there are three objects involved in a distributed transaction is completed, they are:

  • App (application program) (AP): defines transaction boundaries (defined start and end of the transaction)
    and specify the operations make up the transaction. AP can be understood as an interface, service layer,
    tell us need to open the three principles of development affairs in the service layer.
  • Resource Manager (Resource Manager) (RM): As the name suggests,
    the resource manager to manage our shared resources need to access,
    we can understand it as relational databases, file storage system, such as message queue, resource contains such a database,
    file system, printer servers.
  • Transaction Manager (transaction manager) (TM): responsible for managing the global transaction, a transaction that uniquely identifies the assignment,
    execution monitoring the progress of affairs, and is responsible for the transaction commit, rollback, failure recovery.

FAR

Learn the definition of DTP, we look at the XA specification, XA specification describes the global transaction manager (TM)
interface between the local resource manager (RM), this interface is not level programming interface,
but DTO model definition direct interaction between the system interface.

I often see a certain database to support XA protocol, certain middleware supports XA distributed transaction protocol,
and now I understand their meaning, because the number of participants in a distributed transaction,
only if we all follow the same rules of interaction in order to finally complete distributed transaction.

Two-phase commit

(Excerpt from Wikipedia )
two-phase commit protocol (English: Two-phase Commit) refers to computer networks and databases in the field,
one kind of consistency in order to make all nodes performing transactions in the distributed system architecture and design based submission algorithm.
Typically, two-phase commit protocol is also known as a protocol (Protocol). In a distributed system,
each node although the success or failure can be aware of their own operations, but can not know the success or failure of the operation of other nodes.
When a transaction across multiple nodes, in order to maintain the ACID properties of transactions,
needs to be introduced as a component coordinator to unify all the control nodes (referred to as a participant)
is the final operation result and operation result indicating whether or not to genuine nodes submitted
(for example, the updated data is written to disk, and so on). Therefore, the idea of two-phase commit protocol algorithm can be summarized as follows:
Participants will inform the coordinator of the success of the operation,
and then decide based on the feedback information from the coordinator of all participants each participant whether to commit operation or abort the operation.
It should be noted that the two-phase commit protocol (English: 2PC) should not be with the two-stage lock (English: 2PL) concurrency control in confusion.

In simple terms, if the XA two-phase commit protocol is an implementation of the algorithm.

All implementations of the protocol XA distributed transactions and third-party relational database middleware uses 2PC algorithm.

JTA

(Excerpt from Wikipedia )
Java Transaction API (Java Transaction API, referred JTA) is a Java Enterprise Edition application programming interfaces
in a Java environment, allowing complete resources across multiple XA distributed transaction.
JTA was developed under the Java Community Process specifications, number JSR 907. JTA provides:

  • Demarcate transaction boundaries
  • X / Open XA API allows resources to participate in the transaction.

In simple terms, JTA XA protocol is implemented in JAVA, but he only define the appropriate interface and did not give a specific implementation,
in order to complete the distributed transaction, we need to follow to complete their own "two-phase commit" algorithm realization,
or with third-party middleware, such as BTM, atomikos and so on.

to sum up

  1. The definition of DTP distributed transaction process.
  2. The definition of DTP XA interactions in the TM and the RM.
  3. XA implemented by the 2PC algorithm.
  4. Mainly JTA Specification XA JAVA interface description

Guess you like

Origin blog.csdn.net/Little_fxc/article/details/87269703