提问人:geanakuch 提问时间:11/13/2023 更新时间:11/13/2023 访问量:41
如何等待反应器中助焊剂的处置
How to wait for disposal of Flux in Reactor
问:
我正在 Spring Webflux 中使用 Reactor Flux。
我想等待 Flux 的完成(填写列表),同时同时完成其他一些东西。现在我的问题是,我怎样才能等待完成而不必像这样依赖:Thread.sleep
List<MyObject> results = new ArrayList<>();
Disposable disposable = myFlux.subscribe(results::add);
//do some other stuff
//now wait for the flux to finish
while(!disposable.isDisposed()) {
Thread.sleep(500L);
}
return results;
答: 暂无答案
评论
publish
CountDownLatch
myFlux.collectList().zipWith(otherOperationProducingMono)
myFlux.collectList().block()
Mono<List<MyObject>> resultsMono = myFlux.collectList()
resultsMono.block()