【问题标题】:Spring Flux: How does the implemenatation pattern look like if i need to make parallel web service calls using Flux and Spring 5Spring Flux:如果我需要使用 Flux 和 Spring 5 进行并行 Web 服务调用,实现模式会是什么样子
【发布时间】:2017-11-08 22:23:06
【问题描述】:

如果我需要使用 Flux 和 Spring 5 进行并行 Web 服务调用,实现模式是什么样的。基本上,我的目标是并行进行多个 Web 服务调用,并将内容流式传输回浏览器服务执行完成。

【问题讨论】:

    标签: spring flux


    【解决方案1】:

    如果从这些网络服务返回的结果顺序不相关,您可以使用Flux.merge

    根据文档

    将数组/可变参数中包含的 Publisher 序列中的数据合并到交错的合并序列中。

    https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#merge-java.lang.Iterable-

    如果需要值的顺序与发布者的顺序相同,可以使用Flux.mergeSequential

    https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#merge-java.lang.Iterable-

    【讨论】:

      猜你喜欢
      • 2018-12-12
      • 1970-01-01
      • 2021-02-01
      • 2016-06-25
      • 1970-01-01
      • 2021-09-30
      • 2019-12-16
      • 1970-01-01
      • 2018-08-14
      相关资源
      最近更新 更多