栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springcloud seata 1.3使用心得 service模块 undolog序列化问题

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springcloud seata 1.3使用心得 service模块 undolog序列化问题

在使用过程中遇到了两个问题
1、在file.conf 文件中service模块的问题
每个用到seata 的微服务都要注册到seata服务器中,seata服务器去识别每个模块就要通过service 中的 vgroupMapping 在seata 1.3 版本中 默认的 后缀是 -seata-service-group 所以最后在service模块中写的 就是 vgroupMapping.mall-order-seata-service-group = "default"

service {
  #vgroup->rgroup
  # seata 1.3版本 中默认使用  -seata-service-group 结尾
  # mall-order 你的微服务名 spring.application.name
  # -seata-service-group 默认的 后缀 不同版本 不一样
  vgroupMapping.mall-order-seata-service-group = "default"
  #only support single node
  default.grouplist = "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"
}

这一点在源码中可以看出

 private static final Logger LOGGER = LoggerFactory.getLogger(SpringCloudAlibabaConfiguration.class);
    private static final String SPRING_APPLICATION_NAME_KEY = "spring.application.name";
    private static final String DEFAULT_SPRING_CLOUD_SERVICE_GROUP_POSTFIX = "-seata-service-group";
    private String applicationId;
    private String txServiceGroup;
    private ApplicationContext applicationContext;

    
    public String getApplicationId() {
        if (applicationId == null) {
            applicationId = applicationContext.getEnvironment().getProperty(SPRING_APPLICATION_NAME_KEY);
        }
        return applicationId;
    }

    
    public String getTxServiceGroup() {
        if (txServiceGroup == null) {
            String applicationId = getApplicationId();
            if (applicationId == null) {
                LOGGER.warn("{} is null, please set its value", SPRING_APPLICATION_NAME_KEY);
            }
            txServiceGroup = applicationId + DEFAULT_SPRING_CLOUD_SERVICE_GROUP_POSTFIX;
        }
        return txServiceGroup;
    }

2、seata 中 undolog 序列化问题
seata 1.3 版本中 默认的是 jackson无法对时间类型的数据进行序列化,要是用 kryo 进行序列化
将依赖导入到pom

		
            com.esotericsoftware
            kryo
            4.0.2
        
        
            de.javakaffee
            kryo-serializers
            0.42
        

在配置文件中修改序列化方式

seata:
  client:
    undo:
      log-serialization: kryo
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/644664.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号