英文:
Reactive WebClient with synchronous dependency REST call
问题
在实现Service C的A和B的提供者时,是否都应该返回Monos?Service A是同步的是否重要?我的假设是Service A的实现方式不应该重要。在Service C中,我们使用WebClient框架异步发起调用,并在响应准备好时进行订阅。所以A和B都应该被处理为Mono。
有人可以确认这个假设是否正确,或者Service A是否应该以不同的方式处理。谢谢。
英文:
Lets say I have a Service C that makes 2 dependency calls (both dependent services are implemented with Spring Boot):
- Service A - A REST API endpoint that does not return a Mono, so its a synchronous call
- Service B - A REST API endpoint that returns a Mono, so its an asynchronous call
When are are implementing the providers in Service C for A and B using WebClient, should both return Monos? Does it matter that Service A is synchronous? My assumption is that it shouldn't matter how Service A is implemented. In Service C, a Mono, we are letting WebClient framework make the call asynchronously and are subscribing a response when it is ready. So both A and B should be handled as a Mono.
Can anyone confirm if this assumption is correct, or if Service A should be handled differently. Thanks.
答案1
得分: 1
你说得对。无论服务A如何实现,你都可以使用响应式客户端。如果你的应用程序(服务C)是响应式的,甚至可以期望你这样做。
英文:
You are right. No matter how service A is implemented, you could use a reactive client. You even are expected to do so if your application (service C) is reactive.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论