当前位置:网站首页>SEATA distributed transaction
SEATA distributed transaction
2022-07-30 15:32:00 【Study hard and love you hard!】
官方地址
http://seata.io/zh-cn/index.html
参考官网即可
使用
1
Each micro service need to create a UNDO_LOG 表
SEATA AT 模式需要 UNDO_LOG 表
-- 注意此处0.3.0+ 增加唯一索引 ux_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 AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
2
下载seata服务器
从 https://github.com/seata/seata/releases,下载服务器软件包,将其解压缩.
3
导入依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>
4
registry.conf 注册中心配置文件
file.conf Seata配置
nacos中的seataName is registeredserveraddr
5
Each service USESseata 代理数据源
package com.jhj.gulimall.product.config;
import com.zaxxer.hikari.HikariDataSource;
import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
@Configuration
public class MySeataConfig {
@Autowired
DataSourceProperties dataSourceProperties;
@Bean
public DataSource dataSource(DataSourceProperties dataSourceProperties){
HikariDataSource build = dataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
if (StringUtils.hasText(dataSourceProperties.getName())){
build.setPoolName(dataSourceProperties.getName());
}
return new DataSourceProxy(build);
}
}
6
Each service will be file.conf register.conf放到resource下
修改每一个file.conf的service.vgroup_mapping 修改为service.vgroup_mapping.${spring.application.name}-fescar-service-group
A direct way to modifyfile.conf
方式二 配置yml
spring:
cloud:
alibaba:
seata:
tx-service-group: ${
spring.application.name}
启动测试
I want to be distributed over a large transaction entry method combined with @GlobalTransactional The remote call small affairs @Transactional
作者声明
如有问题,欢迎指正!
边栏推荐
- 视频加密的误解
- 【元胞自动机】基于元胞自动机模拟生命演化、病毒感染等实例附matlab代码
- MASM32v11编程调用Process32First失败: 程序发出命令,但命令长度不正确
- 超T动力 盈运天下——中国重汽黄河/豪沃WP14T产品首发荣耀上市!
- 嵌入式开发:嵌入式基础知识——正确启动固件项目的 10 条建议
- 71页全域旅游综合整体解决方案2021 ppt
- Sentinel
- 智能合约安全——私有数据访问
- MySql error: SqlError(Unable to execute query", "Can't create/write to file OS errno 2 - No such file...
- SSE for Web Message Push
猜你喜欢

MaxWell scraped data

算力顶天地,存力纳乾坤:国家超级计算济南中心的一体两面

视频切换播放的例子(视频切换范例)代码

MongoDB starts an error Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)

那些破釜沉舟入局Web3.0的互联网精英都怎么样了?

Distributed pre-course: MySQL implements distributed locks

Smart Contract Security - Private Data Access

国内数字藏品的乱象与未来

【云原生】阿里云ARMS业务实时监控

71-page comprehensive overall solution for global tourism 2021 ppt
随机推荐
超T动力 盈运天下——中国重汽黄河/豪沃WP14T产品首发荣耀上市!
Could not acquire management access for administration
存储器映射、位带操作
定时任务 corn
嵌入式开发:嵌入式基础知识——正确启动固件项目的 10 条建议
LeetCode_数位枚举_困难_233.数字 1 的个数
闭包和装饰器
InputStream和OutputStream流的使用
[In-depth study of 4G/5G/6G topic-46]: 5G Link Adaption Link Adaption-2-Common Abbreviations
MongoDB启动报错 Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
MongoDB starts an error Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
JUC常见的线程池源码学习 02 ( ThreadPoolExecutor 线程池 )
元宇宙邮局AI航天主题系列数字藏品 将于7月30日10:00点上线“元邮数藏”
[Cloud native] Grayscale release, blue-green release, rolling release, grayscale release explanation
有关收集箱的改进建议
Configuration - Notes
CS内网横向移动 模拟渗透实操 超详细
Meta首份元宇宙白皮书9大看点,瞄准80万亿美元市场
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
Office Automation | Office Software and Edraw MindMaster Shortcuts