I am newbie to webflux concepts and trying to understand the background behind communication among three independent Reactive Apps.
Lets suppose there are three services: A, B and C, of which A and B has endpoints that returns Mono<> and C is a Reactive DB.
Consider:
A makes a reactive call to B.
B makes a reactive call to C.
Unless A subscribes, the data flow should'nt have started. This was my understanding.
when I did this in implementation, I could see , when A makes a webclient request to B as below,
//code in Microservice-A
return webClient.get().uri("B").retrieve().bodyToMono(Response.class);
Even though I didnt subscribe , I could see the onNext(data) and onComplete() events fired in logs of microservice B. So clearly my understanding was wrong.
If WebFlux framework in each service is subscribing already, that means it is blocking right. Can anyone please clarify how it works and advantage of this? TIA.
UPDATE: Here is the controller in Microservice-A. Assume this is called from a front end React app where the subscription is actually done.
Can I say, data is prefetched in Microservice - B(at webflux framework level) and it is really upto the TCP network to stream it to Microservice-A depending upon its need
@RestController
public class PandaClController {
@Autowired
WebClient webClient;
@GetMapping("get-panda")
public Mono<Response> getSpotifyData() {
return webClient.get()
.retrieve()
.bodyToMono(Response.class);
}}