首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何找到一个Flux中所有的数据都被处理了,这些数据都是嵌套的Mono(非阻塞)?

如何找到一个Flux中所有的数据都被处理了,这些数据都是嵌套的Mono(非阻塞)?
EN

Stack Overflow用户
提问于 2018-08-02 18:13:35
回答 1查看 820关注 0票数 2

假设我嵌套了下面的Flux和Mono。我有两个不同的Apache Cassandra表的信息。我想合并细节并发送回作为Flux。

请参考下面更新的伪代码。

代码语言:javascript
运行
复制
@Autowired FollowersRepository followersRepository;
@Autowired TopicRepository topicRepository;
    @GetMapping("/info")
    public Flux<FullDetails> getData(){
        return Flux.create(emitter ->{
            followersRepository.findAll() 
            .doOnNext(data -> {
                List<String> all = data.getTopiclist(); //will get list of topic id
                List<Alltopics> processedList = new ArrayList<Alltopics>();
                all.forEach(action -> {
                    topicRepository.findById(action) //will get full detail about topic
                    .doOnSuccess(topic ->{
                        processedList.add(topic);
                        if (processedList.size() >= all.size()) {
                            FullDetails fulldetails = new FullDetails(action,processedList);
                            emitter.next(fulldetails);
                            //emitter.complete();
                        }
                    })
                    .subscribe();
                });
            })
            .doOnComplete(() ->{
                System.out.println("All the data are processed !!!");
                //emitter.complete(); // executing if all the data are pushed from database not waiting for doOnNext method to complete.
            })
            .subscribe();
        });
    }

有关更多详细信息,请参阅此处的代码CodeLink

我已经尝试使用doOnComplete和doOnFinally作为外部通量,它不会等待所有内部非阻塞调用完成。

在处理完Flux中所有嵌套的单声道(非阻塞)请求后,我想调用onComplete。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51651010

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档