I have a scenario with reactive/async call. I am using spring-boot-starter-webflux
and using webclient
to make external HTTP calls.
My scenario is I have to make a call to callA() and then check its response ResponseA. If its ResponseA is ok than exit and return ResponseA.
Otherwise create second request requestB using ResponseA and make a call to callB(). Then check its response ResponseB.
If it is ok then return ResponseA otherwise doRetry on callA().
public Mono<ResponseA> callA(Request1 requestA) {
// calling service-A using webclient
}
public Flux<ResponseB> callB(Request2 requestB) {
// calling service-B using webclient but to create requestB, I need ResponseA.
}
you just need to do some if-statements in a
flatMap
. Probably split it up into some better function names etc. No subscribing, no blocking.