简体   繁体   English

Spring 启动反应式 WebClient 调用旧端点

[英]Spring boot reactive WebClient calling legacy endpoint

In a Spring Boot (2.2.2.RELEASE) application, I have reactive endpoints (returning Mono or Flux), each of them is using reactive WebClient for calling another service.在 Spring Boot (2.2.2.RELEASE) 应用程序中,我有反应式端点(返回 Mono 或 Flux),每个端点都使用反应式 WebClient 来调用另一个服务。 This "other" service is legacy (non-reactive) one.这个“其他”服务是遗留(非反应式)服务。

Here is my question:这是我的问题:

  • Is there a benefit of using Webflux (reactive WebClient) if my reactive endpoint is calling this non-reactive endpoint which does blocking stuff?如果我的反应式端点正在调用这个阻塞的非反应式端点,使用 Webflux(反应式 WebClient)是否有好处?

  • Is my reactive endpoint still reactive?我的反应性端点是否仍然反应性?

If we're talking about HTTP endpoints, we can call them with blocking or non-blocking (asynchronous) clients, but not fully reactive.如果我们谈论 HTTP 端点,我们可以使用阻塞或非阻塞(异步)客户端调用它们,但不能完全响应。

If your "new" application is reactive, you have to use non-blocking client (WebClient in your case), otherwise you will block NIO-threads and loose all the advantages of the reactive approach.如果您的“新”应用程序是反应式的,则必须使用非阻塞客户端(在您的情况下为 WebClient),否则您将阻塞 NIO 线程并失去反应式方法的所有优点。 The fact that the “other” application is blocking doesn't matter, you can still get a less resource-intensive "new" application. “其他”应用程序被阻塞的事实并不重要,您仍然可以获得资源密集程度较低的“新”应用程序。

They are 1. Not fully.它们是 1. 不完全。 2. Your request is not full reactive until you change legacy APIs 2. 在您更改旧 API 之前,您的请求不是完全响应式的

Explanation: End-to-End Reactive pattern only help into to the performance side Currently you're using reactive client this helps to connect to server in two way communication.说明:端到端反应式模式仅有助于性能方面目前您使用的是反应式客户端,这有助于以两种方式通信连接到服务器。 First set of APIs are reactive so web server layer is now reactive but data layer (Legacy APIs ) not reactive第一组 API 是反应性的,因此 Web 服务器层现在是反应性的,但数据层(传统 API)不是反应性的

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM