Reactor系列(十六)disposable停止Flux流
#java#reactor#flux#disposable#
停止flux流
视频讲解: https://www.bilibili.com/video/av81385859/
FluxMonoTestCase.java
package com.example.reactor; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import reactor.core.Disposable; import reactor.core.publisher.Flux; import java.time.Duration; @Slf4j public class FluxMonoTestCase extends BaseTestCase { @Test public void disposable() throws InterruptedException { Flux<Long> longFlux =Flux.interval(Duration.ofMillis(1)); //take方法准确获取订阅数据量 Disposable disposable = longFlux.take(50).subscribe(x->log.info("->{}",x)); //不能停止正在推送数据中的Flux或Mono流 Thread.sleep(100); //彻底停止正在推送数据中的Flux或Mono流 disposable.dispose(); log.info("->Stop"); } }
注公众号,坚持每天3分钟视频学习
相关推荐
flx 2020-08-31
ithzhang 2020-06-21
winc 2020-03-03
第号 2019-11-09
flx 2019-08-25
水龙吟的备忘录 2017-07-12
banana000 2019-07-01
红雪中国 2016-10-08
flx 2019-06-30
凌燕 2019-06-29
banana000 2019-06-29
BrotherWind 2019-06-28
banana000 2019-06-27
LOGGER.info("compose executed");return stringFlux.map(e -> e + "$");LOGGER.info("flatMap executed&qu
flx 2019-06-27
julykobe 2019-06-27
ShaLiWa 2019-06-27
banana000 2019-06-26
flyfelu 2019-06-26