mirror of
https://gitee.com/dromara/Raincat.git
synced 2024-11-30 02:48:48 +08:00
相关的修改
This commit is contained in:
parent
d2e8a64f47
commit
035f5564d8
22
README.md
22
README.md
@ -3,12 +3,26 @@ happylifeplat-transaction
|
||||
|
||||
碧桂园旺生活平台强一致性分布式事务,是基于二阶段提交+本地事务补偿机制来实现。[原理介绍](http://www.hollischuang.com/archives/681)
|
||||
|
||||
基于java语言来开发(JDK1.8),事务发起者,参与者与协调者底层基于netty长连接通信.
|
||||
支持dubbo,springcloud进行分布式事务。
|
||||
基于java语言来开发(JDK1.8),支持dubbo,springcloud进行分布式事务。
|
||||
|
||||
<font color=#FF4500 size=20>因为文件名太长,大家在拉取代码的时候执git命令:git config core.longpaths true</font>
|
||||
|
||||
# Features
|
||||
|
||||
* **框架特性**
|
||||
|
||||
* 支持dubbo,springcloud等rpc框架进行分布式事务。
|
||||
|
||||
* 事务发起者,参与者与协调者底层基于netty长连接通信,稳定高效。
|
||||
|
||||
* 协调者采用eureka做注册中心,支持集群模式。
|
||||
|
||||
* 采用Aspect AOP 切面思想与Spring无缝集成。
|
||||
|
||||
* 配置简单,集成简单,源码简洁,稳定性高,已在生产环境使用。
|
||||
|
||||
* 内置经典的分布式事务场景demo工程,并有swagger-ui可视化界面可以快速体验。
|
||||
|
||||
|
||||
* ***事务角色***
|
||||
|
||||
@ -43,9 +57,9 @@ happylifeplat-transaction
|
||||
|
||||
# Usage
|
||||
|
||||
### [快速体检(dubbo)](https://github.com/yu199195/happylifeplat-transaction/wiki/quick-start-%EF%BC%88dubbo%EF%BC%89)
|
||||
### [快速体验(dubbo)](https://github.com/yu199195/happylifeplat-transaction/wiki/quick-start-%EF%BC%88dubbo%EF%BC%89)
|
||||
|
||||
### [快速体检(springcloud)](https://github.com/yu199195/happylifeplat-transaction/wiki/quick-start-%EF%BC%88springcloud%EF%BC%89)
|
||||
### [快速体验(springcloud)](https://github.com/yu199195/happylifeplat-transaction/wiki/quick-start-%EF%BC%88springcloud%EF%BC%89)
|
||||
|
||||
|
||||
|
||||
|
@ -93,9 +93,11 @@ public class InitServiceImpl implements InitService {
|
||||
final ServiceLoader<TransactionRecoverRepository> recoverRepositories = ServiceBootstrap.loadAll(TransactionRecoverRepository.class);
|
||||
|
||||
|
||||
final Optional<TransactionRecoverRepository> repositoryOptional = StreamSupport.stream(recoverRepositories.spliterator(), false)
|
||||
final Optional<TransactionRecoverRepository> repositoryOptional =
|
||||
StreamSupport.stream(recoverRepositories.spliterator(), false)
|
||||
.filter(recoverRepository ->
|
||||
Objects.equals(recoverRepository.getScheme(), compensationCacheTypeEnum.getCompensationCacheType())).findFirst();
|
||||
Objects.equals(recoverRepository.getScheme(), compensationCacheTypeEnum.getCompensationCacheType()))
|
||||
.findFirst();
|
||||
//将compensationCache实现注入到spring容器
|
||||
repositoryOptional.ifPresent(repository -> {
|
||||
serializer.ifPresent(repository::setSerializer);
|
||||
|
@ -123,12 +123,13 @@ public class FileTransactionRecoverRepository implements TransactionRecoverRepos
|
||||
if (files != null && files.length > 0) {
|
||||
for (File file : files) {
|
||||
TransactionRecover transaction = readTransaction(file);
|
||||
assert transaction != null;
|
||||
transactionRecoverList.add(transaction);
|
||||
/* assert transaction != null;
|
||||
if (transaction.getVersion() == 1) {
|
||||
transactionRecoverList.add(transaction);
|
||||
transaction.setVersion(transaction.getVersion() + 1);
|
||||
writeFile(transaction);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return transactionRecoverList;
|
||||
|
@ -1,22 +1,9 @@
|
||||
package com.happylifeplat.transaction.core.compensation.impl;
|
||||
|
||||
import com.happylifeplat.transaction.core.compensation.TxCompensationService;
|
||||
import com.happylifeplat.transaction.core.compensation.command.TxCompensationAction;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* <p>Description: .</p>
|
||||
* <p>Company: 深圳市旺生活互联网科技有限公司</p>
|
||||
* <p>Copyright: 2015-2017 happylifeplat.com All Rights Reserved</p>
|
||||
*
|
||||
* @author yu.xiao@happylifeplat.com
|
||||
* @version 1.0
|
||||
* @date 2017/7/25 12:26
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public class TxCompensationServiceImplTest {
|
||||
|
||||
|
||||
|
@ -10,16 +10,6 @@ import org.bson.Document;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Description: .</p>
|
||||
* <p>Company: 深圳市旺生活互联网科技有限公司</p>
|
||||
* <p>Copyright: 2015-2017 happylifeplat.com All Rights Reserved</p>
|
||||
*
|
||||
* @author yu.xiao@happylifeplat.com
|
||||
* @version 1.0
|
||||
* @date 2017/8/11 11:46
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public class MongoDbConnectDatabase {
|
||||
|
||||
|
||||
|
@ -12,16 +12,6 @@ import java.util.Optional;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/**
|
||||
* <p>Description: .</p>
|
||||
* <p>Company: 深圳市旺生活互联网科技有限公司</p>
|
||||
* <p>Copyright: 2015-2017 happylifeplat.com All Rights Reserved</p>
|
||||
*
|
||||
* @author yu.xiao@happylifeplat.com
|
||||
* @version 1.0
|
||||
* @date 2017/7/14 10:16
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public class ServiceBootstrapTest {
|
||||
|
||||
/** logger */
|
||||
|
@ -6,7 +6,7 @@ server:
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.1.78:3306/test_1?useUnicode=true&characterEncoding=utf8
|
||||
url: jdbc:mysql://192.168.1.68:3306/test_1?useUnicode=true&characterEncoding=utf8
|
||||
username: xiaoyu
|
||||
password: Wgj@555888
|
||||
application:
|
||||
|
@ -16,7 +16,7 @@
|
||||
<aop:aspectj-autoproxy expose-proxy="true"/>
|
||||
<context:component-scan base-package="com.happylifeplat.transaction.*"/>
|
||||
<bean id="txTransactionBootstrap" class="com.happylifeplat.transaction.core.bootstrap.TxTransactionBootstrap">
|
||||
<property name="txManagerUrl" value="http://192.168.1.66:8761"/>
|
||||
<property name="txManagerUrl" value="http://192.168.1.73:8761"/>
|
||||
<property name="serializer" value="kryo"/>
|
||||
<property name="nettySerializer" value="kryo"/>
|
||||
<property name="blockingQueueType" value="Linked"/>
|
||||
@ -25,7 +25,7 @@
|
||||
<property name="txDbConfig">
|
||||
<bean class="com.happylifeplat.transaction.core.config.TxDbConfig">
|
||||
<property name="url"
|
||||
value="jdbc:mysql://192.168.1.78:3306/order?useUnicode=true&characterEncoding=utf8"/>
|
||||
value="jdbc:mysql://192.168.1.68:3306/order?useUnicode=true&characterEncoding=utf8"/>
|
||||
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
|
||||
<property name="password" value="Wgj@555888"/>
|
||||
<property name="username" value="xiaoyu"/>
|
||||
|
@ -10,9 +10,9 @@
|
||||
<dubbo:application name="tx-dubbo-consume"/>
|
||||
|
||||
|
||||
<dubbo:registry protocol="zookeeper" address="192.168.1.66:2181" />
|
||||
<dubbo:registry protocol="zookeeper" address="192.168.1.73:2181" />
|
||||
|
||||
<dubbo:protocol accesslog="true" name="dubbo" port="20881" host="192.168.1.66" />
|
||||
<dubbo:protocol accesslog="true" name="dubbo" port="20881" host="192.168.1.73" />
|
||||
|
||||
|
||||
<dubbo:reference timeout="5000"
|
||||
|
@ -6,7 +6,7 @@ server:
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.1.78:3306/stock?useUnicode=true&characterEncoding=utf8
|
||||
url: jdbc:mysql://192.168.1.68:3306/stock?useUnicode=true&characterEncoding=utf8
|
||||
username: xiaoyu
|
||||
password: Wgj@555888
|
||||
application:
|
||||
|
@ -15,7 +15,7 @@
|
||||
<context:component-scan base-package="com.happylifeplat.transaction.*"/>
|
||||
<aop:aspectj-autoproxy expose-proxy="true"/>
|
||||
<bean id="txTransactionBootstrap" class="com.happylifeplat.transaction.core.bootstrap.TxTransactionBootstrap">
|
||||
<property name="txManagerUrl" value="http://192.168.1.66:8761"/>
|
||||
<property name="txManagerUrl" value="http://192.168.1.73:8761"/>
|
||||
<property name="serializer" value="kryo"/>
|
||||
<property name="nettySerializer" value="kryo"/>
|
||||
<property name="blockingQueueType" value="Linked"/>
|
||||
@ -24,7 +24,7 @@
|
||||
<property name="txDbConfig">
|
||||
<bean class="com.happylifeplat.transaction.core.config.TxDbConfig">
|
||||
<property name="url"
|
||||
value="jdbc:mysql://192.168.1.78:3306/order?useUnicode=true&characterEncoding=utf8"/>
|
||||
value="jdbc:mysql://192.168.1.68:3306/order?useUnicode=true&characterEncoding=utf8"/>
|
||||
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
|
||||
<property name="password" value="Wgj@555888"/>
|
||||
<property name="username" value="xiaoyu"/>
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
<dubbo:application name="tx-dubbo-stock"/>
|
||||
|
||||
<dubbo:registry protocol="zookeeper" address="192.168.1.66:2181" />
|
||||
<dubbo:registry protocol="zookeeper" address="192.168.1.73:2181" />
|
||||
|
||||
<dubbo:protocol accesslog="true" name="dubbo" port="20882" host="192.168.1.66" />
|
||||
<dubbo:protocol accesslog="true" name="dubbo" port="20882" host="192.168.1.73" />
|
||||
|
||||
|
||||
<dubbo:service interface="com.happylifeplat.transaction.tx.dubbo.sample.stock.api.service.StockService" ref="stockService" />
|
||||
|
@ -14,12 +14,6 @@
|
||||
<dependency>
|
||||
<groupId>com.happylifeplat.transaction</groupId>
|
||||
<artifactId>happylifeplat-transaction-tx-springcloud</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -87,19 +81,6 @@
|
||||
<version>1.0.29</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<!– mybatis核心包 –>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>3.2.6</version>
|
||||
</dependency>
|
||||
<!– mybatis/spring包 –>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<version>1.2.2</version>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -21,12 +21,13 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {MongoAutoConfiguration.class,MongoDataAutoConfiguration.class})
|
||||
@EnableEurekaClient
|
||||
@EnableFeignClients
|
||||
@ImportResource({"classpath:applicationContext.xml"})
|
||||
|
@ -16,12 +16,6 @@
|
||||
<dependency>
|
||||
<groupId>com.happylifeplat.transaction</groupId>
|
||||
<artifactId>happylifeplat-transaction-tx-springcloud</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
@ -21,12 +21,13 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {MongoAutoConfiguration.class,MongoDataAutoConfiguration.class})
|
||||
@EnableEurekaClient
|
||||
@EnableFeignClients
|
||||
@ImportResource({"classpath:applicationContext.xml"})
|
||||
|
@ -15,12 +15,6 @@
|
||||
<dependency>
|
||||
<groupId>com.happylifeplat.transaction</groupId>
|
||||
<artifactId>happylifeplat-transaction-tx-springcloud</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -21,12 +21,13 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {MongoAutoConfiguration.class,MongoDataAutoConfiguration.class})
|
||||
@EnableEurekaClient
|
||||
@EnableFeignClients
|
||||
@MapperScan("com.happylifeplat.transaction.tx.springcloud.sample.wechat.mapper")
|
||||
|
34
pom.xml
34
pom.xml
@ -62,8 +62,8 @@
|
||||
<developer>
|
||||
<id>xiaoyu</id>
|
||||
<name>xiaoyu(Myth)</name>
|
||||
<email>yu.xiao@happylifeplat.com</email>
|
||||
<organization>happylife</organization>
|
||||
<email>549477611@qq.com</email>
|
||||
<organization>free</organization>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
@ -94,12 +94,13 @@
|
||||
<protostuff.version>1.0.8</protostuff.version>
|
||||
<kryo.version>4.0.0</kryo.version>
|
||||
<curator.version>2.9.1</curator.version>
|
||||
<nettty.version>4.1.12.Final</nettty.version>
|
||||
<netty.version>4.1.12.Final</netty.version>
|
||||
<commons.httpclient.version>3.0.1</commons.httpclient.version>
|
||||
<httpclient.version>4.5.1</httpclient.version>
|
||||
<okhttp.version>3.7.0</okhttp.version>
|
||||
<gson.verions>2.6.2</gson.verions>
|
||||
<druid.version>1.0.29</druid.version>
|
||||
<springfox.version>2.6.1</springfox.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@ -373,7 +374,7 @@
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>${nettty.version}</version>
|
||||
<version>${netty.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -388,6 +389,22 @@
|
||||
<version>0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-bean-validators</artifactId>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
@ -416,6 +433,15 @@
|
||||
<target>${jdk.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<configuration>
|
||||
<tagNameFormat>v@{project.version}</tagNameFormat>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user