Skip to content

Commit

Permalink
feat: SpringCloud F version and Spring Boot 2.0.x support
Browse files Browse the repository at this point in the history
  • Loading branch information
skyesx committed Feb 17, 2019
1 parent eeb9393 commit d129ae8
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 76 deletions.
28 changes: 23 additions & 5 deletions easytrans-core/pom.xml
Expand Up @@ -66,12 +66,30 @@



<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>

<dependency>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
Expand Down
10 changes: 1 addition & 9 deletions easytrans-demo/interface-call/pom.xml
Expand Up @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<revision>1.1.3</revision>
<revision>1.2.0</revision>
</properties>


Expand All @@ -32,14 +32,6 @@
<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
<artifactId>easytrans</artifactId>
Expand Down
10 changes: 1 addition & 9 deletions easytrans-demo/rpc-dubbo/pom.xml
Expand Up @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<revision>1.1.3</revision>
<revision>1.2.0</revision>
</properties>


Expand All @@ -32,14 +32,6 @@
<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
<artifactId>easytrans</artifactId>
Expand Down
10 changes: 1 addition & 9 deletions easytrans-demo/sagatcc/pom.xml
Expand Up @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<revision>1.1.3</revision>
<revision>1.2.0</revision>
</properties>


Expand All @@ -32,14 +32,6 @@
<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
<artifactId>easytrans</artifactId>
Expand Down
33 changes: 22 additions & 11 deletions easytrans-demo/tcc-and-fescar/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.13.RELEASE</version>
<version>2.0.8.RELEASE</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -34,22 +34,26 @@
<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
<artifactId>easytrans</artifactId>
<artifactId>easytrans-starter</artifactId>
<version>${revision}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
<artifactId>easytrans-core</artifactId>
<version>${revision}</version>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans.demos</groupId>
<artifactId>tccandfescar-wallet-api</artifactId>
Expand Down Expand Up @@ -78,6 +82,13 @@
<artifactId>tccandfescar-order-service</artifactId>
<version>${revision}</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down
Expand Up @@ -45,6 +45,11 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

</dependencies>

Expand Down
Expand Up @@ -55,6 +55,11 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

</dependencies>

Expand Down
Expand Up @@ -45,6 +45,11 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

</dependencies>

Expand Down
10 changes: 1 addition & 9 deletions easytrans-demo/tcc-and-msg/pom.xml
Expand Up @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<revision>1.1.3</revision>
<revision>1.2.0</revision>
</properties>


Expand All @@ -34,14 +34,6 @@
<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
<artifactId>easytrans</artifactId>
Expand Down
10 changes: 1 addition & 9 deletions easytrans-demo/tcc-only/pom.xml
Expand Up @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<revision>1.1.3</revision>
<revision>1.2.0</revision>
</properties>


Expand All @@ -31,14 +31,6 @@

<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
Expand Down
1 change: 1 addition & 0 deletions easytrans-demo/tcc-only/tcconly-order-service/pom.xml
Expand Up @@ -36,6 +36,7 @@
<artifactId>tcconly-wallet-api</artifactId>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion easytrans-log-database-starter/pom.xml
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.5</version>
<version>1.1.13</version>
</dependency>


Expand Down
4 changes: 2 additions & 2 deletions easytrans-rpc-rest-ribbon-starter/pom.xml
Expand Up @@ -26,10 +26,10 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>
</dependency>

</dependencies>

Expand Down
25 changes: 20 additions & 5 deletions pom.xml
Expand Up @@ -59,23 +59,21 @@
</modules>


<parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<!-- <version>1.4.4.RELEASE</version> -->
</parent>

<dependencyManagement>
<dependencies>
<dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<!-- <version>Camden.SR7</version> -->
<type>pom</type>
<scope>import</scope>
</dependency>
</dependency>

<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
Expand Down Expand Up @@ -125,6 +123,23 @@
<version>${revision}</version>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>4.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.10</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
3 changes: 3 additions & 0 deletions readme-en.md
@@ -1,3 +1,6 @@
This article a bit outofdate, some new function has been added , you can refer readme.md in Chinese for news, or you can submit an issue to let me know you want me to update this article


# English
(English is not my native language, can someone help me to review the text below?)

Expand Down
22 changes: 15 additions & 7 deletions readme.md
Expand Up @@ -43,7 +43,7 @@
* 适用于需要获取远程执行结果来决定逻辑事务走向 且 可以进行补偿的业务
* 若使用消息队列不能解决的事务问题优先考虑使用基于补偿的最终一致性事务(若需要嵌套事务,则使用TCC)
* 本框架中传统补偿不支持嵌套,若有需要,可改用TCC
* 使用自动补偿完成的最终一致性事务(参考阿里Fescar的AT模式,目前处于Alpha状态,仅供熟悉原理代码能自行排坑者使用
* 使用自动补偿完成的最终一致性事务(整合改造阿里的Fescar的AT模式完成
* 适用于需要获取远程执行结果来决定逻辑事务走向 且 不介意偶尔读取并展示脏数据的场景
* 该模式下,普通select时数据整体处于脏读状态,进行本地更新事务时,若进行逻辑判断所需的字段会参与到全局事务时,需要用Select for update获取准确值后再判断
* 因上述全局事务及本地事务的协作是一个隐式、易错点,甚至于写每一个涉及更新的SQL都需要考虑上面这个因素,因此希望引入并使用自动补偿时,需建立好相关使用规范,以避免后续项目失控
Expand Down Expand Up @@ -96,11 +96,9 @@
<dependency>
<groupId>com.yiqiniu.easytrans</groupId>
<artifactId>easytrans-starter</artifactId>
<version>1.2.0-beta</version>
<version>1.2.0</version>
</dependency>

目前稳定版本为 1.1.3,生产请使用该版本

Starter里包含了若干默认的组件实现:基于mysql的分布式事务日志存储,基于ribbon-rest的RPC实现,基于KAFKA的消息队列,若不需要或者要替换,可以EXCLUDE掉


Expand Down Expand Up @@ -388,7 +386,17 @@ Starter里包含了若干默认的组件实现:基于mysql的分布式事务日
* 因此CRASH恢复进程使用select for update 查询executed_trans记录时,必然能得到准确的是否已经提交的结果(若主控事务仍在进行中,select for update将会等待)
* 使用select for update是为了避免在MVCC情况下错误查询出最终事务提交结果的情况

## 七、其他
## 七、外部组件版本兼容性
* ZK请使用3.4及以上版本
* SpringBoot 2.0.x 以及 SpringCloud F版本的整合请参考Demo里的tccandfescar
* 需要注意的是写文档时最新版的spring boot(2.0.8)引入的最新版mysql-connector-java (5.1.47)存在bug,要降级为5.1.46
* 另因SpringCloud大版本变更时导致某些包名变动,在F版本时使用ET的Ribbon时,需要在项目单独引入spring-cloud-starter-netflix-ribbon
* 如果遇到ZK库相关的包匹配问题,需要检查当前项目的相关包版本
* 在1.2.0版本后,curator-recipes及curator-framework需为4.x.x,zookeeper客户端版本需为3.4.x或者3.5.x(视ZK服务器版本而定)
* 1.2.0版本前,curator-recipes及curator-framework需为2..x.x,zookeeper客户端版本同上


## 八、其他
欢迎加作者个人微信公众号

![wechat public account](https://raw.githubusercontent.com/QNJR-GROUP/ImageHub/master/easytrans/wechat_public_account.jpg)
Expand All @@ -398,8 +406,8 @@ Starter里包含了若干默认的组件实现:基于mysql的分布式事务日
email: skyes.xu@qq.com

我写的关于ET的一些额外文章,请点赞以帮助SEO:
如何选择分布式事务形态 https://www.cnblogs.com/skyesx/p/9697817.html
“若干分布式事务框架”与“我的偏见” https://www.cnblogs.com/skyesx/p/10041923.html
* 如何选择分布式事务形态 https://www.cnblogs.com/skyesx/p/9697817.html
* “若干分布式事务框架”与“我的偏见” https://www.cnblogs.com/skyesx/p/10041923.html



Expand Down

0 comments on commit d129ae8

Please sign in to comment.