Gracefully Switching Off Background Threads

Dear Flowable experts,

Is there a functionality in the Engine to gracefully pause all the background threads and switch them (all) back on if needed?

The reason for the question is the following use case: we make use of the Flowable engine in cloud environment where blue-green deployments happen on a regular basis. In this case, temporarily, there are 2 times as many application nodes, as in a normal case. Half of them are excluded from the HTTP routing, though. But the background threads are still active for these nodes, making use of the sparse resources (e.g. DB or messaging connections). We would need to have more control over that.

Thank you!

Best regards,

Are these spring boot applications, if so it could simply be a matter of setting the property flowable.process.async-executor-activate=false and restarting the instances.

Thank you very much for the response! No, we don’t make use of spring boot.

BTW, we’ve come across the AsyncExecutor#shutdown function. How graceful is it?

Best regards,

Looking at the code in the DefaultAsyncJobExecutor, it looks like it gives executing jobs a minute to finish what they are doing:

    protected void stopExecutingAsyncJobs() {
        if (executorService != null) {

            // Ask the thread pool to finish and exit

            // Waits for 1 minute to finish all currently executing jobs
            try {
                if (!executorService.awaitTermination(secondsToWaitOnShutdown, TimeUnit.SECONDS)) {
                    LOGGER.warn("Timeout during shutdown of async job executor. The current running jobs could not end within {} seconds after shutdown operation.",
            } catch (InterruptedException e) {
                LOGGER.warn("Interrupted while shutting down the async job executor. ", e);

            executorService = null;
1 Like

shutdown() of the async executor is indeed gracefully (within the minute @wwitt is mentioning. This is a configurable timeout). We actually use this in unit tests to boot up and shut down the jobs to control exactly when jobs should be able to be picked up.


Thank you @wwitt and @joram!
We’ll make use of the functionality.