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

seata xid can't transmit if use httpclient #2862

Closed
zhuangzhuangdashen opened this issue Oct 26, 2022 · 4 comments · May be fixed by #2875
Closed

seata xid can't transmit if use httpclient #2862

zhuangzhuangdashen opened this issue Oct 26, 2022 · 4 comments · May be fixed by #2875
Labels

Comments

@zhuangzhuangdashen
Copy link

具体描述:引入httpclient组件后seata无法透传xid
源码表现为Feign调用不会进入SeataFeignClient类的execute方法
把httpclient组件依赖去除掉之后可以正常透传

材料

  1. httpclient依赖pom
io.github.openfeign feign-httpclient 10.0.1
  1. spring-cloud-alibaba-seata版本为2.2.0-RELEASE
  2. feign-core 9.7
  3. spring-cloud-starter-openfeign-core 2.0.2.RELEASE
@zhuangzhuangdashen
Copy link
Author

Wish your reply, thanks

@HaojunRen
Copy link
Collaborator

HaojunRen commented Oct 26, 2022

Refer to code as blow:

public class  MyInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
         String xid = RequestContextHolder.getRequestAttributes().getRequest().getHeader("xid");
         requestTemplate.header("xid", xid);
    }
}

RequestContextHolder is a threadlocal class based on Spring Web Context. You need to pay attention to async scene, that means threadlocal value will be lost with async scene

@github-actions
Copy link

This issue has been open 30 days with no activity. This will be closed in 7 days.

@github-actions github-actions bot added the stale label Oct 16, 2023
Copy link

github-actions bot commented Nov 6, 2023

This issue has been automatically marked as stale because it hasn't had any recent activity.If you think this should still be open, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for your interest and contribution to the Sping Cloud Alibaba Community.

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

Successfully merging a pull request may close this issue.

2 participants