private void fillTaskQueueAsync() {
        if (allowTaskQueueFill) {
            if (fillingQueue.compareAndSet(false, true)) {
                try {
                    needToFillQueue.set(false);

                    LOGGER.debug("fillTaskQueueAsync() - Executing fillTaskQueue");
                    securityContext.asProcessingUser(() ->
                            CompletableFuture
                                    .supplyAsync(taskContextFactory.contextResult(
                                                    "Fill task queue",
                                                    (taskContext) ->
                                                            queueNewTasks(taskContext)),
                                            executor)
                                    .whenComplete((result, error) -> {
                                        try {
                                            if (error != null) {
                                                LOGGER.error("Error filling task queue:" + error.getMessage(), error);
                                            }

                                            if (allowTaskQueueFill && (error != null || result == 0)) {
                                                ThreadUtil.sleep(processorConfigProvider.get()
                                                        .getWaitToQueueTasksDuration().toMillis());
                                            }
                                        } finally {
                                            fillingQueue.set(false);
                                        }

                                        // See if we are required to fill again.
                                        if (needToFillQueue.get()) {
                                            fillTaskQueueAsync();
                                        }
                                    }));
                } catch (final RuntimeException e) {
                    fillingQueue.set(false);
                    LOGGER.error(e::getMessage, e);
                }
            } else {
                needToFillQueue.set(true);
            }
        }
    }
Return the next task to perform. Called by worker threads. Also assigns
the task to the node asking for the job
stroom-processor/stroom-processor-impl/src/main/java/stroom/processor/impl/ProcessorTaskQueueManagerImpl.java