当前位置:网站首页>TCC of distributed solutions
TCC of distributed solutions
2022-07-05 22:29:00 【Melting pole】
summary
What is? TCC Business
TCC yes Try、Confirm、Cancel Abbreviations of three words ,TCC Each branch transaction is required to implement three operations : Preprocessing Try、 confirm Confirm、 revoke Cancel.Try Do business check and resource reservation ,Confirm Do business confirmation ,Cancel To achieve a relationship with Try The reverse operation is the rollback operation .TM Initiate all branch transactions first try operation , Of any branch transaction try Operation execution failed ,TM Will initiate all branch transactions Cancel operation , if try The operation was all successful ,TM Will initiate all branch transactions Confirm operation , among Confirm/Cancel If the operation fails ,TM Will try again .
TCC There are three stages :
- Try The stage is to do business inspection ( Uniformity ) And resource reservation ( Isolation ), This stage is only a preliminary operation , It and the following Confirm Together to really form a complete business logic .
- Confirm The stage is to make a confirmation submission ,Try Start execution after all branch transactions of phase are executed successfully Confirm. Usually , use TCC Think Confirm There is no mistake in the stage . namely : Only Try success ,Confirm It must be successful . if Confirm The stage really went wrong , Need to introduce retry mechanism or manual processing .
- Cancel The phase is to cancel the branch transaction when the business execution error needs to be rolled back , Reserve resource release . Usually , use TCC Think Cancel Stage is also a certain success . if Cancel The stage really went wrong , Need to introduce retry mechanism or manual processing .
- TM Business management
TM The transaction manager can be implemented as a stand-alone service , You can also have the global transaction initiator act as TM Role ,TM Independent to be a common component , In order to consider the system structure and software reuse .
TM Generate a global transaction record when initiating a global transaction , Global transaction ID Throughout the chain of distributed transaction calls , Used to record transaction context , Track and record status , because Confirm and Cancel Failure needs to be retried , So we need to be idempotent , Idempotency refers to the same operation, no matter how many times it is requested , The results are the same .
TCC Solution
Currently on the market TCC There are many frameworks, such as the following :
( The following data collection date is 2019 year 07 month 11 Japan )
tcc-transaction:https://github.com/changmingxie/tcc-transaction
Hmily:https://github.com/dromara/hmily
ByteTCC:https://github.com/liuyangming/ByteTC
EasyTransaction:https://github.com/QNJR-GROUP/EasyTransaction
What was said in the previous section Seata Also support TCC, but Seata Of TCC Pattern configuration is relatively complex . Our goal is to understand TCC And the process of coordinated operation of affairs , So it's more of a lightweight, easy to understand framework , So... Was finally determined Hmily.
Hmily It's a high-performance distributed transaction TCC Open source framework . be based on Java Language to develop (JDK1.8), Support Dubbo,Spring Cloud etc. RPC Framework for distributed transactions . It currently supports the following features :
- Support nested transactions (Nested transaction support).
- use disruptor The framework reads and writes transaction logs asynchronously , And RPC There is no difference in the performance of the framework .
- Support SpringBoot-starter Project start , Easy to use .
- RPC Framework support :dubbo,motan,springCloud.
- Local transaction storage support :redis,mongodb,zookeeper,file,mysql.
- Transaction log serialization support :java,hessian,kryo,protostuff.
- use Aspect AOP To think in a face-to-face way Spring Seamless integration , Natural support cluster .
- RPC Transaction recovery , Timeout abnormal recovery, etc .
Hmily utilize AOP Intercept local and remote methods involved in distributed transactions , By intercepting , Transaction participants can transparently call the Try、Confirm、Cancel Method ; Pass transaction context ; And record the transaction log , Make compensation as appropriate , Retry etc. .
Hmily There is no need for transaction coordination services , But you need to provide a database (mysql/mongodb/zookeeper/redis/file) To store logs .
Hmily Realized TCC Service is the same as ordinary service , Just expose one interface , That's what it is Try Business .Confirm/cancel Business logic , Just because of global transaction commit / Rollback needs to be provided , therefore Confirm/Cancel Business only needs to be Hmily TCC Transaction framework discovery . It doesn't need to be perceived by other business services that call it .
website :https://dromara.org/website/zh-cn/docs/hmily/index.html
TCC Note that the three exception handling methods are null rollback 、 idempotent 、 Hang
Empty rollback
idempotent
Hang
边栏推荐
- 实战:fabric 用户证书吊销操作流程
- 如何快速体验OneOS
- 509. Fibonacci Number. Sol
- Common interview questions of JVM manufacturers
- C language - structural basis
- Damn, window in ie open()
- Go语言学习教程(十五)
- Analysis of the problem that the cookie value in PHP contains a plus sign (+) and becomes a space
- Pl/sql basic case
- 数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
猜你喜欢

A trip to Suzhou during the Dragon Boat Festival holiday
![Sparse array [matrix]](/img/62/27b02deeeaa5028a16219ef51ccf82.jpg)
Sparse array [matrix]

Two stage locking protocol for concurrency control

2022 Software Test Engineer salary increase strategy, how to reach 30K in three years

从 1.5 开始搭建一个微服务框架——日志追踪 traceId

Nanjing: full use of electronic contracts for commercial housing sales

50. Pow(x, n). O(logN) Sol

Postman核心功能解析-参数化和测试报告

Business learning of mall commodity module
![[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)](/img/3e/34b45cd14f0302bb381efd244bc68f.jpg)
[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)
随机推荐
Nacos installation and service registration
70. Climbing Stairs. Sol
Granularity of blocking of concurrency control
How can Bluetooth in notebook computer be used to connect headphones
opencv 判断点在多边形内外
Platformio create libopencm3 + FreeRTOS project
[Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial
谷歌地图案例
如何创建线程
Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
Pl/sql basic case
2022软件测试工程师涨薪攻略,3年如何达到30K
Qtquick3d real time reflection
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
119. Pascal‘s Triangle II. Sol
Three "factions" in the metauniverse
点到直线的距离直线的交点及夹角
Win11运行cmd提示“请求的操作需要提升”的解决方法
GWT module may need to be (RE) compiled reduce - GWT module may need to be (RE) compiled reduce