Local transaction ACID we should all know, unified commit, failure rollback, strictly ensure the consistency of data within the same transaction! Distributed transactions do not implement this ACID, which can only implement two of the CAP principles, a widely used prototype for distributed transactions. CAP(Consistency, Availability, Partition Tolerance) elaborates three main aspects of a distributed system, which can only be realized by choosing two at the same time. Common CP system, AP system.
Several frameworks have emerged in the industry for the principles applied to CP and AP:
CP system has two-phase commit (strong consistency)
AP systems have TCC(compensated transaction)
Aspnetcore-cap is an asynchronous messaging solution that meets the ultimate consistency. It provides a solution for mysql and sqlserver. The message queue can be kafka or rabbitmq. The source code is open source on Github, and the package is available on Nuget!
Understanding of message-assured – ultimate consistency distributed transactions:
-
- Service A submits data
-
- Sends a message to the message center
-
- The message center pushes messages to subscribers
-
- Subscribers handle their own business logic
-
- Failure to repeatedly retry until success, rather than strong consistency, roll back A