【发布时间】:2018-05-25 11:55:51
【问题描述】:
Flux<Integer> shared = Flux.just(1, 2).share();
shared.subscribe(System.out::println);
shared.subscribe(System.out::println);
由于share() 将通量变为热门,我希望第一个订阅者获得所有值,而第二个订阅者没有获得任何值,因为在订阅时流已经完成。但是输出和没有share一样:1 2 1 2,但应该只是1 2。
当我将 share() 替换为 publish.autoconnect() 时,它按预期工作。这是为什么呢?
【问题讨论】:
标签: project-reactor