java - ParallelFlux - Parallel Execution with multiple downstream API calls - Stack Overflow

I have 3 input IDs, which should be processed parallely. For that I have used ParallelFlux as below.Fo

I have 3 input IDs, which should be processed parallely. For that I have used ParallelFlux as below.

For every ID, there are 2 downstream API calls(mono1 and mono2 as below) that needs to be parallely invoked as well.

Will it be possible projectReactor?

I tried with following code. With parallel flux, each id will be processed with different threads. But the downstream calls will be sequential with same assigned thread.

Flux.fromIterable(idList)
    .parallel()
    .runOn(Schedulers.boundedElastic()
    .flatMap(id -> Mono.fromCallable(()-> Pair.of(id, getInfoByID(id))))
    .sequential()
    .collect(Collector.toList()).block();
private Info getInfoByID(String id){
      var mono1= api1.getDetails();
      var mono2= api2.getDetails();
      Mono.zip(mono1, mono2)
      .map(tuple2 -> {
       …………
       }).block();
}

Thanks

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744111738a4558982.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信