- Notifications
You must be signed in to change notification settings - Fork20
Official java client for distributed transaction framework dtm
License
dtm-labs/dtmcli-java
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
English |简体中文
dtmcli-java is the Java client SDK for distributed transaction managerdtm
DTM is a distributed transaction framework which provides cross-service eventual data consistency. It provides saga, tcc, xa, 2-phase message, outbox patterns for a variety of application scenarios. It also supports multiple languages and multiple store engine to form up a transaction as following:
- Support for multiple languages: Go, Java, PHP, C#, Python, Nodejs SDKs
- Support for multiple transaction patterns: SAGA, TCC, XA
- Support for OutBox pattern: 2-phase messages, a more elegant solution than OutBox
- Support for multiple database transactions: Mysql, Redis, MongoDB, Postgres, TDSQL, etc.
- Support for multiple storage engines: Mysql (common), Redis (high performance), MongoDB (in planning)
- Support for multiple microservices architectures:go-zero, go-kratos/kratos, polarismesh/polaris
- Support for high availability and easy horizontal scaling
- Springcloud Projects
- If the version of springboot >= 2.4.0, choose a corresponding version of dtmcli-springcloud.
- If the version of springboot <> 2.4.0, use dtmcli-java, it provide the interfaces for micro-services, please set the configuration for nacos.
- Not Springcloud Projects.
- use dtmcli-java,and set your configurations.
| artifact | version | dtmcli-java version | remark |
|---|---|---|---|
| dtmcli-springcloud | 2.1.4.1 | 2.4.0 <= springboot version < 2.5.13 | for springboot >= 2.5.0,please set spring.cloud.compatibility-verifier.enabled=false |
| dtmcli-springcloud | 2.1.4.2 | 2.6.0 <= springboot version < 2.6.latest | |
| dtmcli-java | 2.1.4 | others |
Maven:
<dependency><groupId>io.github.dtm-labs</groupId><artifactId>dtmcli-springcloud</artifactId><version>${dtmcli.version}</version></dependency>
Gradle:
dependencies { implementation'io.github.dtm-labs:dtmcli-springcloud:${dtmcli.version}'}If you are using dtmcli-java,new a file nameddtm-conf.properties
- Case 1: Using naceos
serverAddr=127.0.0.1:8848username=nacospassword=nacosnamespace=c3dc917d-906a-429d-90a9-85012b41014edtm.service.name=dtmServicedtm.service.registryType=nacos- Case 2: Connect to dtmsvr directly
dtm.ipport=127.0.0.1:36789@RequestMapping("testTcc") public StringtestTcc() { // new dtm clinet DtmClient dtmClient = new DtmClient(ipPort); //create TCC transaction try {dtmClient.tccGlobalTransaction(dtmClient.genGid(), TccTestController::tccTrans); } catch (Exception e) { log.error("tccGlobalTransaction error", e);return"fail"; }return"success"; }/*** define TCC sub-transactions by calling callBranch** @param tcc* @return* @see TransController*/ public static void tccTrans(Tcc tcc) throws Exception { Response outResponse = tcc .callBranch("", svc +"/TransOutTry", svc +"/TransOutConfirm", svc +"/TransOutCancel"); log.info("outResponse:{}", outResponse); Response inResponse = tcc.callBranch("", svc +"/TransInTry", svc +"/TransInConfirm", svc +"/TransInCancel"); log.info("inResponse:{}", inResponse); }
About
Official java client for distributed transaction framework dtm
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.
