Search code examples
javaspringspring-bootreactivespring-webclient

Reactive WebClient with synchronous dependency REST call


Lets say I have a Service C that makes 2 dependency calls (both dependent services are implemented with Spring Boot):

  1. Service A - A REST API endpoint that does not return a Mono, so its a synchronous call
  2. 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.


Solution

  • 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.