I have an Amazon SQS Listener configured in a Spring Boot application. After receiving a message of the queue, it has to call a REST API.

The call fails with this error

java.lang.IllegalStateException: 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.
   at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131)

The REST Template is trying to read some attributes off the RequestContextHolder and it doesn't have the Web context. Unfortunately, I don't have access to the Rest template to change it (it is in a library).

What can I do in this case?

0

There are 0 best solutions below