当前位置: 首页 > 工具软件 > API-requestor > 使用案例 >

MQ队列消费时报异常:No thread-bound request found

蔺敏达
2023-12-01

No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

主要原因:

代码中调用了HttpServletRequest对象,而MQ队列消费执行时是没有通过Web API调用。

RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();

 

 

 类似资料: