-2

I am trying to get all the responses from flux but sometimes I'm getting all the response and sometimes I'm not getting only few responses. Can anyone please help me on this. I have attached the picture for reference. I don't want to subscribe to that flux. I want those data's for manipulation.

urls i have key as name and url as value.

    public LinkedHashMap<String String> getDummyHealthData (Map<String Strings urls) {
        LinkedHashMap<String, String> urlMap=new LinkedHashMap<>();
Mono.when(Flux. fromStreamCurls.entryset().stream().log().flatmap(url->webclientBuilder.build().get().uri(url.getValue()).retrieve().bodyToMono (string.class). onSuccessorError((res,err)->{ urlMap.put(uri.getKey(),res);    )}
        ).OnErrorResume (e->Mono.empty)).block(); System.out.println(urlMap) 
 return urlMap;
}
Ajay D
  • 1
  • 2

1 Answers1

0

onErrorResume operator will not help you to resume the stream.
If you want to get all response, you need to process error.
You can write doOnError to process exceptions. Code may be below:
doOnError(e -> urlMap.put(uri.getKey(), "defaultString"))

shanfeng
  • 503
  • 2
  • 14