A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.
A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.
English | 简体中文
DTM is a distributed transaction framework which provides cross-service eventual data consistency. It provides saga, tcc, xa, 2-phase message, outbox, workflow patterns for a variety of application scenarios. It also supports multiple languages and multiple store engine to form up a transaction as following:
DTM can be applied to data consistency issues in a large number of scenarios, here are a few common ones
git clone https://github.com/dtm-labs/dtm && cd dtm
go run main.goSuppose we want to perform an inter-bank transfer. The operations of transfer out (TransOut) and transfer in (TransIn) are coded in separate micro-services.
Here is an example to illustrate a solution of dtm to this problem:
git clone https://github.com/dtm-labs/quick-start-sample.git && cd quick-start-sample/workflow-grpc
go run main.go…When the above code runs, we can see in the console that services TransOut, TransIn has been called.
If any forward operation fails, DTM invokes the corresponding compensating operation of each sub-transaction to roll back, after which the transaction is successfully rolled back.
Let's purposely trigger the failure of the second sub-transaction and watch what happens
// req := busi.BusiReq{Amount: 30, TransInResult: ""}
req := busi.BusiReq{Amount: 30, TransInResult: "FAILURE"}
})we can see in the console that services TransOut, TransIn, TransOutRevert has been called
If you want more quick start examples, please refer to dtm-labs/quick-start-sample
The above example mainly demonstrates the flow of a distributed transaction. More on this, including practical examples of how to interact with an actual database, how to do compensation, how to do rollback, etc. please refer to dtm-examples for more examples.
If you think this project is interesting, or helpful to you, please give a star!
go版本的client SDK版本号有点混乱是否可以整理一下呢
Vulnerability in dtm project
Are there plans to wrap DTM as an MCP server for AI integration, following the model of go-zero's mcp-zero?
go client install
en.dtm.pub TLS certificate appears valid (could not reproduce issue)
workflow other error can't backoff retery and RetryInterval is invalid
Saga模式下,分支事务超时问题
是否可以支持nacos和goframe
gozero的rpc直连dtm,执行事务时错误
dtm 中 driver 为 postgres ,如何指定sslmode ?