一、环境搭建
①首先,我们采用的是Eureka作为Seata的配置中心,所以先启动EurekaServer
②下载seata-server-0.9.0.zip,解压,修改配置文件
registry.conf
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "eureka"
eureka {
serviceUrl = "http://admin:123456@127.0.0.1:8001/eureka,http://admin:123456@127.0.0.1:8002/eureka"
application = "seata-server"
weight = "1"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
file {
name = "file.conf"
}
}
file.conf
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
worker-thread-prefix = "NettyServerNIOWorker"
server-executor-thread-prefix = "NettyServerBizHandler"
share-boss-worker = false
client-selector-thread-prefix = "NettyClientSelector"
client-selector-thread-size = 1
client-worker-thread-prefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss-thread-size = 1
#auto default pin or 8
worker-thread-size = 8
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#vgroup->rgroup
vgroup_mapping.my_test_tx_group = "default"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
disableGlobalTransaction = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
}
client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
}
## transaction log store
store {
## store mode: file、db
mode = "db"
## file store
file {
dir = "sessionStore"
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
# async, sync
flush-disk-mode = async
}
## database store
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.
datasource = "dbcp"
## mysql/oracle/h2/oceanbase etc.
db-type = "mysql"
driver-class-name = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://192.168.190.131:3306/seata-server"
user = "root"
password = "123456"
min-conn = 1
max-conn = 3
global.table = "global_table"
branch.table = "branch_table"
lock-table = "lock_table"
query-limit = 100
}
}
lock {
## the lock store mode: local、remote
mode = "remote"
local {
## store locks in user's database
}
remote {
## store locks in the seata's server
}
}
recovery {
#schedule committing retry period in milliseconds
committing-retry-period = 1000
#schedule asyn committing retry period in milliseconds
asyn-committing-retry-period = 1000
#schedule rollbacking retry period in milliseconds
rollbacking-retry-period = 1000
#schedule timeout retry period in milliseconds
timeout-retry-period = 1000
}
transaction {
undo.data.validation = true
undo.log.serialization = "jackson"
undo.log.save.days = 7
#schedule delete expired undo_log in milliseconds
undo.log.delete.period = 86400000
undo.log.table = "undo_log"
}
## metrics settings
metrics {
enabled = false
registry-type = "compact"
# multi exporters use comma divided
exporter-list = "prometheus"
exporter-prometheus-port = 9898
}
support {
## spring
spring {
# auto proxy the DataSource bean
datasource.autoproxy = false
}
}
数据库脚本(3306端口seata-server数据库)
DROP TABLE IF EXISTS `global_table`;
CREATE TABLE `global_table` (
`xid` varchar(128) NOT NULL,
`transaction_id` bigint(20) DEFAULT NULL,
`status` tinyint(4) NOT NULL,
`application_id` varchar(32) DEFAULT NULL,
`transaction_service_group` varchar(32) DEFAULT NULL,
`transaction_name` varchar(128) DEFAULT NULL,
`timeout` int(11) DEFAULT NULL,
`begin_time` bigint(20) DEFAULT NULL,
`application_data` varchar(2000) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`xid`),
KEY `idx_gmt_modified_status` (`gmt_modified`,`status`),
KEY `idx_transaction_id` (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `lock_table`;
CREATE TABLE `lock_table` (
`row_key` varchar(128) NOT NULL,
`xid` varchar(96) DEFAULT NULL,
`transaction_id` mediumtext,
`branch_id` mediumtext,
`resource_id` varchar(256) DEFAULT NULL,
`table_name` varchar(32) DEFAULT NULL,
`pk` varchar(36) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`row_key`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `branch_table`;
CREATE TABLE `branch_table` (
`branch_id` bigint(20) NOT NULL,
`xid` varchar(128) NOT NULL,
`transaction_id` bigint(20) DEFAULT NULL,
`resource_group_id` varchar(32) DEFAULT NULL,
`resource_id` varchar(256) DEFAULT NULL,
`lock_key` varchar(128) DEFAULT NULL,
`branch_type` varchar(8) DEFAULT NULL,
`status` tinyint(4) DEFAULT NULL,
`client_id` varchar(64) DEFAULT NULL,
`application_data` varchar(2000) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`branch_id`),
KEY `idx_xid` (`xid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
点击seata-server.bat启动,将Seata-Server注册到Eureka上
③创建Seata父级工程,以及Account服务,Storage服务
父级pom.xml(SpringCloud版本Finchley.SR4,SpringBoot版本2.0.0.RELEASE)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yj</groupId>
<artifactId>Seata</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Seata</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<modules>
<module>Order</module>
<module>Account</module>
<module>Storage</module>
<module>Eureka</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Account服务pom文件
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yj</groupId>
<artifactId>Seata</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Account</artifactId>
<name>Account</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!--Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--openfeign接口定义 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--seata -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>2.1.0.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>seata-all</artifactId>
<groupId>io.seata</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-all</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--Eureka Client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
</project>
Storage服务pom文件
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yj</groupId>
<artifactId>Seata</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Storage</artifactId>
<name>Storage</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>2.1.0.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>seata-all</artifactId>
<groupId>io.seata</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-all</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
Application文件
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
DataSourceProxyConfig
package com.yj.account.config;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import com.alibaba.druid.pool.DruidDataSource;
import io.seata.rm.datasource.DataSourceProxy;
@Configuration
public class DataSourceProxyConfig {
@Value("${mybatis.mapper-locations}")
private String mapperLocations;
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource druidDataSource() {
return new DruidDataSource();
}
@Bean
public DataSourceProxy dataSourceProxy(DataSource dataSource) {
return new DataSourceProxy(dataSource);
}
@Bean
public SqlSessionFactory sqlSessionFactoryBean(DataSourceProxy dataSourceProxy) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSourceProxy);
sqlSessionFactoryBean
.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory());
return sqlSessionFactoryBean.getObject();
}
}
application.properties
server.port=8003
spring.application.name=seata-account
eureka.client.serviceUrl.defaultZone=http://admin:123456@127.0.0.1:8001/eureka,http://admin:123456@127.0.0.1:8002/eureka
eureka.instance.prefer-ip-address=true
eureka.instance.instance-id=192.168.190.1:8003
eureka.instance.hostname=192.168.190.1
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://192.168.190.131:3307/seata-account?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
spring.datasource.username = root
spring.datasource.password = 123456
spring.datasource.type= com.alibaba.druid.pool.DruidDataSource
spring.datasource.initialSize= 5
spring.datasource.minIdle= 5
spring.datasource.maxActive= 20
spring.datasource.maxWait= 60000
spring.datasource.timeBetweenEvictionRunsMillis= 60000
spring.datasource.minEvictableIdleTimeMillis= 300000
spring.datasource.validationQuery= SELECT 1 FROM DUAL
spring.datasource.testWhileIdle= true
spring.datasource.testOnBorrow= false
spring.datasource.testOnReturn= false
spring.datasource.poolPreparedStatements= true
spring.datasource.maxPoolPreparedStatementPerConnectionSize= 20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
spring.datasource.filters= stat,wall,log4j
spring.datasource.connectionProperties= druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
#配置mybatis
mybatis.config-location=classpath:mybatis-config.xml
mybatis.mapper-locations=classpath:mapper/*.xml
#配置seata
spring.cloud.alibaba.seata.tx-service-group=my_test_tx_group
将Seata-Server中的file.conf和register.conf文件复制过来,并修改file.conf文件中的分组名称为seata-server
service {
#vgroup->rgroup
vgroup_mapping.my_test_tx_group = "seata-server"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
disableGlobalTransaction = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
}
④AccountService添加一个本地事务,一个Seata分布式事务
package com.yj.account.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yj.account.dao.AccountDao;
import com.yj.account.feign.FeignService;
import io.seata.spring.annotation.GlobalTransactional;
@Service
public class AccountService {
private static final Logger log = LoggerFactory.getLogger(AccountService.class);
@Autowired
private AccountDao accountDao;
@Autowired
private FeignService feignService;
/**
* 本地事务
*/
@Transactional
public String localTransaction(Long userId, long productId, String flag) {
bisiness(userId, productId, flag);
return "下单成功";
}
/**
* seata分布式事务
*
*/
@GlobalTransactional(name = "create-order", rollbackFor = Exception.class)
public String seataTransaction(Long userId, long productId, String flag) {
bisiness(userId, productId, flag);
return "下单成功";
}
private void bisiness(long userId, long productId, String flag) {
feignService.updateStorage(productId);
if ("1".equals(flag)) {
int i = 1 / 0;
}
log.info("==账户服务扣减账户余额开始==");
accountDao.updateAccount(userId);
log.info("==账户服务扣减账户余额结束==");
}
}
⑤两个数据库脚本,Account数据库(3307端口seata-account数据库)新增account表以及undo_log表,Storage数据库(3308端口seata-storage数据库)新增storage表以及undo_log表
DROP TABLE IF EXISTS `account`;
CREATE TABLE `account` (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`user_id` bigint(11) DEFAULT NULL COMMENT '用户id',
`money` decimal(10,0) DEFAULT NULL COMMENT '余额',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
INSERT INTO `account` VALUES ('1', '1', '100');
DROP TABLE IF EXISTS `storage`;
CREATE TABLE `storage` (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`product_id` bigint(11) DEFAULT NULL COMMENT '用户id',
`num` int(10) DEFAULT NULL COMMENT '总额度',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
INSERT INTO `storage` VALUES ('1', '1', '10');
DROP TABLE IF EXISTS `undo_log`;
CREATE TABLE `undo_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`branch_id` bigint(20) NOT NULL,
`xid` varchar(100) NOT NULL,
`context` varchar(128) NOT NULL,
`rollback_info` longblob NOT NULL,
`log_status` int(11) NOT NULL,
`log_created` datetime NOT NULL,
`log_modified` datetime NOT NULL,
`ext` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
启动Account,Storage服务,成功后,Eureka中注册的服务展示如下
二、验证
流程是这样,调用下单接口,Account服务首先通过Feign的方式调用Storage服务扣减库存,成功后,Account服务再扣减账户余额
①本地事务
http://127.0.0.1:8003/localTransaction?user_id=1&product_id=1&flag=1
发生异常时,库存服务的库存扣减了,可是账户服务的用户余额没扣减,因为Storage服务的事务已经提交,即使Account服务后续报错了,Storage服务中的事务也无法再回滚
②Seata分布式事务
http://127.0.0.1:8003/seataTransaction?user_id=1&product_id=1&flag=1
发生异常时,库存服务的库存不会扣减,全局事务生效并回滚了
Account服务日志输出如下:
2020-01-18 11:30:54.326 INFO 10792 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: seata-storage.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2020-01-18 11:30:54.402 INFO 10792 --- [nio-8003-exec-1] i.seata.tm.api.DefaultGlobalTransaction : [192.168.190.1:8091:2033046197] rollback status: Rollbacked
2020-01-18 11:30:54.407 ERROR 10792 --- [nio-8003-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ArithmeticException: / by zero] with root cause
java.lang.ArithmeticException: / by zero
Storage服务日志输出如下:
2020-01-18 11:30:53.670 INFO 11924 --- [nio-8004-exec-1] com.yj.storage.service.StorageService : ==库存服务扣减库存开始==
2020-01-18 11:30:53.705 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.rm.report.retry.count, try to use default value instead.
2020-01-18 11:30:53.706 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.report.success.enable, try to use default value instead.
2020-01-18 11:30:53.707 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.rm.lock.retry.policy.branch-rollback-on-conflict, try to use default value instead.
2020-01-18 11:30:53.710 DEBUG 11924 --- [nio-8004-exec-1] c.y.s.dao.StorageDao.updateStorage : ==> Preparing: update storage set num = num-1 where product_id = ?
2020-01-18 11:30:53.917 DEBUG 11924 --- [nio-8004-exec-1] c.y.s.dao.StorageDao.updateStorage : ==> Parameters: 1(Long)
2020-01-18 11:30:53.925 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.rm.lock.retry.internal, try to use default value instead.
2020-01-18 11:30:53.926 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.rm.lock.retry.times, try to use default value instead.
2020-01-18 11:30:54.085 INFO 11924 --- [nio-8004-exec-1] i.s.common.loader.EnhancedServiceLoader : load LoadBalance[null] extension by class[io.seata.discovery.loadbalance.RandomLoadBalance]
2020-01-18 11:30:54.175 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.undo.log.table, try to use default value instead.
2020-01-18 11:30:54.177 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.undo.log.serialization, try to use default value instead.
2020-01-18 11:30:54.191 WARN 11924 --- [nio-8004-exec-1] i.s.common.loader.EnhancedServiceLoader : load [io.seata.rm.datasource.undo.parser.ProtostuffUndoLogParser] class fail. io/protostuff/runtime/Delegate
2020-01-18 11:30:54.192 INFO 11924 --- [nio-8004-exec-1] i.s.common.loader.EnhancedServiceLoader : load UndoLogParser[jackson] extension by class[io.seata.rm.datasource.undo.parser.JacksonUndoLogParser]
2020-01-18 11:30:54.239 DEBUG 11924 --- [nio-8004-exec-1] c.y.s.dao.StorageDao.updateStorage : <== Updates: 1
2020-01-18 11:30:54.239 INFO 11924 --- [nio-8004-exec-1] com.yj.storage.service.StorageService : ==库存服务扣库存结束==
2020-01-18 11:30:54.320 INFO 11924 --- [atch_RMROLE_1_8] i.s.core.rpc.netty.RmMessageListener : onMessage:xid=192.168.190.1:8091:2033046197,branchId=2033046200,branchType=AT,resourceId=jdbc:mysql://192.168.190.131:3308/seata-storage,applicationData=null
2020-01-18 11:30:54.321 INFO 11924 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 192.168.190.1:8091:2033046197 2033046200 jdbc:mysql://192.168.190.131:3308/seata-storage
2020-01-18 11:30:54.372 WARN 11924 --- [nfigOperate_2_2] io.seata.config.FileConfiguration : Could not found property client.undo.data.validation, try to use default value instead.
2020-01-18 11:30:54.384 INFO 11924 --- [atch_RMROLE_1_8] i.s.r.d.undo.AbstractUndoLogManager : xid 192.168.190.1:8091:2033046197 branch 2033046200, undo_log deleted with GlobalFinished
2020-01-18 11:30:54.386 INFO 11924 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
SeataServer日志输出如下
2020-01-18 11:30:43.050 INFO [NettyServerNIOWorker_4_8]io.seata.core.rpc.DefaultServerMessageListenerImpl.onRegTmMessage:133 -checkAuth for client:192.168.190.1:59824 vgroup:my_test_tx_group ok
2020-01-18 11:30:52.645 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:198 -SeataMergeMessage timeout=60000,transactionName=create-order
,clientIp:192.168.190.1,vgroup:my_test_tx_group
2020-01-18 11:30:52.746 INFO [ServerHandlerThread_3_500]io.seata.server.coordinator.DefaultCore.begin:145 -Successfully begin global transaction xid = 192.168.190.1:8091:2033046197
2020-01-18 11:30:54.099 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:198 -SeataMergeMessage xid=192.168.190.1:8091:2033046197,branchType=AT,resourceId=jdbc:mysql://192.168.190.131:3308/seata-storage,lockKey=storage:1
,clientIp:192.168.190.1,vgroup:my_test_tx_group
2020-01-18 11:30:54.121 INFO [ServerHandlerThread_4_500]io.seata.common.loader.EnhancedServiceLoader.loadFile:236 -load LockStore[DB] extension by class[io.seata.core.store.db.LockStoreDataBaseDAO]
2020-01-18 11:30:54.122 INFO [ServerHandlerThread_4_500]io.seata.common.loader.EnhancedServiceLoader.loadFile:236 -load Locker[db] extension by class[io.seata.server.lock.db.DataBaseLocker]
2020-01-18 11:30:54.166 INFO [ServerHandlerThread_4_500]io.seata.server.coordinator.DefaultCore.lambda$branchRegister$0:94 -Successfully register branch xid = 192.168.190.1:8091:2033046197, branchId = 2033046200
2020-01-18 11:30:54.217 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:198 -SeataMergeMessage xid=192.168.190.1:8091:2033046197,branchId=2033046200,resourceId=null,status=PhaseOne_Done,applicationData=null
,clientIp:192.168.190.1,vgroup:my_test_tx_group
2020-01-18 11:30:54.232 INFO [ServerHandlerThread_5_500]io.seata.server.coordinator.DefaultCore.branchReport:118 -Successfully branch report xid = 192.168.190.1:8091:2033046197, branchId = 2033046200
2020-01-18 11:30:54.293 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:198 -SeataMergeMessage xid=192.168.190.1:8091:2033046197,extraData=null
,clientIp:192.168.190.1,vgroup:my_test_tx_group
2020-01-18 11:30:54.393 INFO [ServerHandlerThread_6_500]io.seata.server.coordinator.DefaultCore.doGlobalRollback:405 -Successfully rollback branch xid=192.168.190.1:8091:2033046197 branchId=2033046200
2020-01-18 11:30:54.400 INFO [ServerHandlerThread_6_500]io.seata.server.coordinator.DefaultCore.doGlobalRollback:437 -Successfully rollback global, xid = 192.168.190.1:8091:2033046197
生产环境的SeataServer最好以集群的方式运行,待验证