File.conf
主要配置应用名称和seata server地址
vgroup_mapping.${spring.application.name}-fescar-service-group="default"
default.grouplist = "127.0.0.1:8091"
Registry.conf
编写Entity
编写Repository
编写Service
编写代码Controller
DataSource
zero-provider-b
配置同zero-provider-a工程,编写相应的业务逻辑。
在处理添加业务时,抛出异常。
zero-consumer
配置同zero-provider-a工程,编写相应的业务逻辑。
feignClient
feignclient
Service
Controller
测试
启动Seata Server
启动Mysql,并初始化(每个库都要创建undo_log表)
DROP SCHEMA IF EXISTS zeroa;
CREATE SCHEMA zeroa;
USE zeroa;
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 AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
DROP SCHEMA IF EXISTS zerob;
CREATE SCHEMA zerob;
USE zerob;
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 AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
启动
zero-discovery-server
zero-gateway-server
zero-provider-a
zero-provider-b
zero-consumer
添加数据