dromara / hmily

Distributed transaction solutions
https://dromara.org
Apache License 2.0
4.11k stars 1.41k forks source link

HmilyTcc,服务实现端一直报错 #336

Open grape-pzz opened 2 years ago

grape-pzz commented 2 years ago

服务实现端一直报如下错误: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected ':' at line 1 column 49 path $.participantId

grape-pzz commented 2 years ago

找到原因了: 1、服务消费端会在拦截器中将事务信息存到request的header中,如下 public class HmilyFeignInterceptor implements RequestInterceptor {

@Override
public void apply(final RequestTemplate requestTemplate) {
    RpcMediator.getInstance().transmit(requestTemplate::header, HmilyContextHolder.get());
}

} 2、高版本的RestTemplate.headers会将事务(json字符串)信息截取,导致服务接收端解析json格式失败 {"transId":-5821096666862862336,"participantId":-5821096650890952704,"action":1,"role":1,"transType":"TCC"} 截取成{"transId":-5821096666862862336,"participantId} 存到header的“_HMILY_TRANSACTION_CONTEXT”中

考虑降低springcloud的版本或者重写这个拦截器