feign问题和解决

springcloud 寻梦 4年前 (2020-06-07) 747次浏览 0个评论 扫描二维码
文章目录[隐藏]

feign传递oauth2-token的问题和解决

在使用spring OAuth2时,远程调用使用feign,需要在请求头中加入token信息,在使用hystrix熔断时,造成无法添加token信息,配置文件加入

# 熔断
feign.hystrix.enabled=true
hystrix.command.default.execution.isolation.strategy=SEMAPHORE

其真实原因待解决,网上说是 线程策略冲突问题造成的权限问题,hystrix 默认的线程策略是thread。也就是说在 hystrix启用状态下,当执行feignclient 调用的时候,会另起一个线程,导致安全上下问题传递不到子线程中。

参考

https://blog.csdn.net/xiyang_1990/article/details/102286851
https://blog.csdn.net/yudar1024/article/details/76070214

feign和async异步

feign之间传递oauth2-token的问题和解决

主线程添加RequestContextHolder.setRequestAttributes(RequestContextHolder.getRequestAttributes(),true);

喜欢 (0)
[支付宝扫码,感谢支持]
分享 (0)
关于作者:

您必须 登录 才能发表评论!