In-depth understanding of Spring transaction principles
The Spring transaction
Distributed transaction
1. What are distributed transactions
2. Causes of distributed transactions
2.1. Database classification and table
Review images
2.2 soA-BASED application
Review images
3. ACID properties of transactions
3.1 Atomicity (A)
3.2 Consistency (C)
3.3 Isolation (I)
3.4 Persistence (D)
4. Application scenarios of distributed transactions
4.1, payment
4.2 place orders online
5. Common distributed transaction solutions
5.1 Two-phase commit based on XA protocol
Review images
5.2. Message transaction + Final consistency
Review images
- If step 1 fails, the transaction fails and the local operation of A is not performed
- If step 2 fails, the transaction fails and the local operation of A is not performed
- Step 3 error, this time need to roll back the prepared message, how to roll back? The answer is that system A implements A callback interface of the messaging middleware, which continuously executes the callback interface to check whether the transaction execution of A is successful, and rolls back the prepared message if it fails
- Step 4 failed. In this case, the local transaction of A was successful. Should the message-oriented middleware roll back A? The answer is no, in fact, through the callback interface, the message middleware can check the successful execution of A, at this time, there is no need for A to send the message, the message middleware can submit the message itself, so as to complete the whole message transaction
Review images