LaySwift 2019-12-31
#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分钟视频学习
LOGGER.info("compose executed");return stringFlux.map(e -> e + "$");LOGGER.info("flatMap executed&qu