Can someone please guide me as I am new to the flux and trying to understand how to handle this scenario?
Issue: I am getting readTimeout exception in one of the flux responses from getResp()
method below and then all the prior successful responses are ignored and the exception error is returned.
Instead, I want to return all the successful responses I received prior to the exception.
public Flux<CustomObject1> getInfo(List<RequestObj> requestObjList) {
return requestObjList.stream()
.parallel()
.map(this::getResp)
.reduce(Flux::Merge)
.orElse(Flux.empty());
}
public Flux<CustomObject1> getResp(RequestObj requestObj){
// process the request and return ...
}
Please let me know if this is not clear, happy to provide more details.
There are several ways to handle errors in
flatMap
Use
flatMapDelayError
that will delay any error until all elements are processedHandle error for every element