Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
grape-pzz opened this issue Jul 5, 2022 · 1 comment
Open

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

grape-pzz opened this issue Jul 5, 2022 · 1 comment

Comments

@grape-pzz
Copy link

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

@grape-pzz
Copy link
Author

grape-pzz commented Jul 14, 2022

找到原因了:
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的版本或者重写这个拦截器

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant