Weso
Weso

Reputation: 408

Spring boot - Threads / Feign-Client / Messaging / Streamlistener

We struggle to find a solution for the following scenario:

Situation

We want to avoid passing every request header on the method call and like the central configuration approach of the request interceptors.

Problem:

How to access data from a specific message, which contains informations, that need to be added to every request call via the Feign-RequestInterceptor. We don't have a Request-Context, as we come from a message.

Can we be sure , that the message consumption and the REST call is happening on the same thread? If yes, we could use the NamedThreadLocal to store the information.

Upvotes: 1

Views: 702

Answers (1)

Gary Russell
Gary Russell

Reputation: 174554

Yes, unless you hand off to another thread in your StreamListener, the rest call will be made on the same thread (assuming you are using RestTemplate and not the reactive web client).

Upvotes: 1

Related Questions