I'm quite newbie in webflux and I want to do the following thing: I want to make parallel http requests to the same url with different parameter values and to stop when I get the first non null (and non exceptional) result. I'm following the example from here https://www.baeldung.com/spring-webclient-simultaneous-calls but I have no idea how to stop when I got the result. Can anybody help me? Currently I have something like this:
RetrySpec retrySpec = Retry.max(3);
return webClient.get().uri("/getMyObject/{id}", id)
.retrieve()
.bodyToMono(MyObject.class)
.retryWhen(retrySpec);
}
public Flux<> getMyObjs(List<String> ids) {
return Flux.fromIterable(ids)
.parallel(Runtime.getRuntime().availableProcessors())
.runOn()
.flatMap(this::getMyObject)
.;//// Stop when I get first non exceptional value
}