Reactor链还在吗运行

Is Reactor chain still running

我有一个基于 Spring WebFlux 和 Reactor 的应用程序。应用程序每天按计划启动并加载统计信息。但是也可以通过控制器手动启动选项。因此,如果我的应用程序仍然是 运行 而有人想通过控制器启动应用程序,则可能会发生冲突。这就是为什么我需要一个工具来检测我的 Reactor 链是否仍然是 运行。 如果是,则抛出异常(或者可能只是消息)并且应用程序应该忽略来自控制器的调用并继续加载统计而不是被中断。是否有现成的工具可用于此任务?有一个简单的布尔复选框解决方案,但是 WebFlux/Reactor 是否提供这种功能? 反应器链看起来像:

Mono.fromRunnable(() -> {
            log.info("Scheduled update has been started.");
            service1.doSmth1();
        })
                .then(Mono.fromRunnable(() -> log.info("Scheduled names collecting has been started.")))
                .then(service2.doSmth2())
                .then(Mono.fromRunnable(() -> log.info("Scheduled orders collectins has been started")))
                .then(service3.doSmth3())
                .then(Mono.fromRunnable(() -> log.info("Scheduled update has finished.")))
                .then()
                .doOnSuccess(a -> log.info("Finished updating stats."))
                .doOnError(throwable -> log.error("{}", throwable.getMessage()));

没有这样的内置功能。此处可以使用 AtomicBoolean 状态,可以通过添加 doFinally(signal -> isRunningFlag.compareAndSet(true, false)).

在链的末尾更新状态