在使用过程中遇到了两个问题
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;
/**
* Gets application id.
*
* @return the application id
*/
public String getApplicationId() {
if (applicationId == null) {
applicationId = applicationContext.getEnvironment().getProperty(SPRING_APPLICATION_NAME_KEY);
}
return applicationId;
}
/**
* Gets tx service group.
*
* @return the tx service group
*/
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
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>de.javakaffee</groupId>
<artifactId>kryo-serializers</artifactId>
<version>0.42</version>
</dependency>
在配置文件中修改序列化方式
seata:
client:
undo:
log-serialization: kryo