标签:isp 订阅 top get ase extends not lan code
#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分钟视频学习
Reactor系列(十六)disposable停止Flux流
标签:isp 订阅 top get ase extends not lan code
原文地址:https://www.cnblogs.com/JavaWeiBianCheng/p/12123578.html