我是靠谱客的博主 现实哑铃,这篇文章主要介绍RequestContextHolder.getRequestAttributes()为空与hystrix关系,现在分享给大家,希望可以做个参考。

ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

对于被hystrix注解的controller方法,其线程与其对应切面线程不一致,导致attributes为空

 

2021-02-25/15:17:46.422 logback [http-nio-8000-exec-3] INFO  c.y.kjcxweb.aop.RateLimiterAspect - aspect----- doAround threadName:Thread[http-nio-8000-exec-3,5,main]
2021-02-25/15:17:49.648 logback [hystrix-lx-1] INFO  c.y.k.m.c.i.WaybillRecordsController - controller----queryLx threadName:Thread[hystrix-lx-1,5,main]
2021-02-25/15:17:49.648 logback [hystrix-lx-1] INFO  c.y.k.m.s.i.WaybillRecordsServiceImpl - service-------serviceLx threadName:Thread[hystrix-lx-1,5,main]

最后

以上就是现实哑铃最近收集整理的关于RequestContextHolder.getRequestAttributes()为空与hystrix关系的全部内容,更多相关RequestContextHolder内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部