简体   繁体   English

Spring Boot - 线程 / Feign-Client / 消息 / Streamlistener

[英]Spring boot - Threads / Feign-Client / Messaging / Streamlistener

We struggle to find a solution for the following scenario:我们努力为以下场景找到解决方案:

Situation情况

  • Receive a message via Spring Cloud Streamlistener通过 Spring Cloud Streamlistener 接收消息

  • Invoke a REST-Service via Feign-Client通过 Feign-Client 调用 REST-Service

  • We have configured several Feign-RequestInterceptor to enrich request header data.我们配置了几个 Feign-RequestInterceptor 来丰富请求头数据。

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.如何从包含信息的特定消息中访问数据,这些信息需要通过 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?我们可以确定消息消费和 REST 调用发生在同一个线程上吗? If yes, we could use the NamedThreadLocal to store the information.如果是,我们可以使用 NamedThreadLocal 来存储信息。

是的,除非您RestTemplate给 StreamListener 中的另一个线程,否则其余调用将在同一线程上进行(假设您使用的是RestTemplate而不是反应式 Web 客户端)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从spring-cloud-netflix-feign在Feign-Client中设置HostnameVerifier - How to set HostnameVerifier in Feign-Client from spring-cloud-netflix-feign 如何通过当前请求的 Feign 拦截器将动态 header 值添加到 feign-client? - How to add dynamic header values to feign-client through Feign interceptor from current request? Spring Boot假装异常 - Spring Boot feign exception 如何使用 Spring Boot feign 客户端进行 Oauth2 身份验证? - How to use Spring Boot feign client for Oauth2 authentication? Feign客户端,Spring Boot应用程序和rx / Observable类未找到错误 - Feign Client, Spring Boot Application, and rx/Observable Class Not Found Error 如何在Spring Boot应用程序中的Feign客户端上使用WireMock? - How to use WireMock on a Feign client in a Spring Boot application? Spring Boot hatoas + swagger +feign 客户端错误应用启动 - Spring Boot hateoas + swagger +feign client error application start up Spring Boot 2 - 自动装配服务时对 Feign 客户端的依赖不满意 - Spring Boot 2 - Unsatisfied dependency on Feign client when autowired for service 如何使用 postman 或 feign 客户端在 Spring 引导中将值设置为 @RequestAttribute - How to set value to @RequestAttribute in Spring boot using postman or feign client OAuth + Feign with Scheduled in Spring Boot - OAuth + Feign with Scheduled in Spring Boot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM