Is Reactor chain still running

Tags: , ,

I have an application based on Spring WebFlux and Reactor. Application starts everyday on a schedule and loads statistics. But there is also available a manual launch option through controller. So if my app is still running and somebody wants to start app through controller, conflicts may happen. Thats why I need a tool to detect if my Reactor chain is still running or not. If yes, then throw exception (or maybe just message) and app should ignore call from controller and continue load statistics instead of being interrupted. Is there any tools ready to be applied for this task? There is a simple boolean checkbox solution, but does WebFlux/Reactor provides this kind of feature? Reactor chain looks like:

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


There is no such built-in feature. An AtomicBoolean state could be used here, which can be updated at the end of the chain by adding a doFinally(signal -> isRunningFlag.compareAndSet(true, false)).

Source: stackoverflow