Continue to iterate via flux.fromStream even after exception is thrown for one of the element

Viewed 31
  public Mono<ResponseEntity<Data>> getData(@RequestParam List<String> tagIds){
   
   Flux<S3Object> s3ObjectFlux = Flux.fromStream(tagIds.stream())
           .parallel()
           .runOn(Schedulers.boundedElastic())
           .flatMap(id -> fetchResources(id)) //S3Exception is thrown here for one of the element 
       .sequential() 
    //here what should I use to catch the exception, log and continue 
           .ordered((u1, u2) -> u2.hashCode() - u1.hashCode());

   Mono<Data> data = s3ObjectFlux.collectList()
           .map(s3Objects -> new Data(s3Objects));  
}

I am iterating through tagIds and fetching the s3 objects here, if the object is not there or any exception is thrown, I want to log, ignore it, and continue with next. With all onError* I tried it just breaks the iterations and I get empty list at the end

0 Answers
Related