spring cloud nacos集成分布式事务框架seata 1.1.0

本文介绍了如何将Seata 1.1.0集成到Spring Cloud Nacos环境中,包括Seata和Nacos的下载、配置文件修改、数据库脚本执行、服务操作等步骤。在实验中,通过创建订单并调用用户服务更新余额的场景,展示了全局事务的使用,强调了在主事务方法中开启GlobalTransactional以及在用户服务中添加特定注解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

seata下载地址
官方文档
版本升级指南值得关注
nacos下载地址

以下代码都在我的github
试验服务有3个
controla : 网关
order :订单
user :用户
模拟业务流程:订单插入一条记录后调用用户服务更新用户余额,在用户余额手动报错

1.修改seata配置文件
1.1file.conf


## transaction log store, only used in seata-server
service {
   
  #vgroup->rgroup
  # 主要改的地方1
  vgroup-mapping.fsp_tx_group = "default" #修改事务组名称为:fsp_tx_group,和客户端自定义的名称对应
  #only support single node
  # 主要改的地方2
  grouplist.default = "127.0.0.1:8091"
  #degrade current not support
  enableDegrade = false
  #disable
  disable = 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"
}
store {
   
  ## store mode: file、db
  # 改成db
  mode = "db"

  ## file store property
  file {
   
    ## store location dir
    dir = "sessionStore"
    # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
    maxBranchSessionSize = 16384
    # globe session size , if exceeded throws exceptions
    maxGlobalSessionSize = 512
    # file buffer size , if exceeded allocate new buffer
    fileWriteBufferCacheSize = 16384
    # when recover batch read size
    sessionReloadReadSize = 100
    # async, sync
    flushDiskMode = async
  }

  ## database store property
  db {
   
    ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.
    datasource = "dbcp"
    ## mysql/oracle/h2/oceanbase etc.
    dbType = "mysql"
    driverClassName &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值