private void consumeFromQueue() {
        try {
            // We are called in an infinite while loop so drop out every 2s to allow
            // checking of shutdown state
            final DelayedRefreshable delayedRefreshable = delayQueue.poll(2, TimeUnit.SECONDS);
            if (delayedRefreshable != null) {
                try {
                    final Refreshable refreshable = delayedRefreshable.getRefreshable();
                    // We've removed it from the queue so keep the set in sync with the queue.
                    uuidsInQueue.remove(refreshable.getUuid());


                    if (refreshable.isActive()) {
                        // It is possible that someone getting the token has triggered a synchronous refresh,
                        // so we may not need to do it.
                        LOGGER.debug(() -> LogUtil.message("Consumed {}", itemToString(delayedRefreshable)));
                        final boolean didRefresh = refreshable.refreshIfRequired(RefreshMode.EAGER);
                        LOGGER.debug(() -> LogUtil.message("{} refresh of {}",
                                (didRefresh
                                        ? "Did"
                                        : "Didn't"),
                                itemToString(delayedRefreshable)));

                        // We need to add the refreshable that we may have just refreshed back onto the queue
                        // with its new expiry time
                        addOrUpdate(refreshable);
                    } else {
                        LOGGER.debug(() -> LogUtil.message("Consumed in-active {}", itemToString(delayedRefreshable)));
                    }

                } catch (Exception e) {
                    LOGGER.error("Error consuming {} - {}",
                            itemToString(delayedRefreshable), LogUtil.exceptionMessage(e), e);
                    // We have to log, swallow and carry on, else our single thread dies
                }
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            LOGGER.debug("Refresh delay queue interrupted, assume shutdown is happening so do no more");
        }
    }
Register the refreshable so that its refreshing gets managed. Can be called many times
for the same {@link Refreshable}, e.g. to notify the {@link RefreshManager} that it was
refreshed externally.
stroom-security/stroom-security-common-impl/src/main/java/stroom/security/common/impl/RefreshManager.java