React堆链还在运行吗

9fkzdhlc  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(192)

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

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()));
34gzjxbg

34gzjxbg1#

没有这种内置功能。一 AtomicBoolean 在这里可以使用state,它可以通过添加 doFinally(signal -> isRunningFlag.compareAndSet(true, false)) .

相关问题