private void removeRedundantSharedKafkaProducers() {
        boolean didRemoveElements = allSharedProducersMap.values().removeIf(sharedKafkaProducer ->
                sharedKafkaProducer.isSuperseded() && sharedKafkaProducer.getUseCount() <= 0);
        if (LOGGER.isDebugEnabled()) {
            if (didRemoveElements) {
                // If removeRedundantSharedKafkaProducers is called before we add the new one then the size
                // may be zero
                LOGGER.debug("Removed items from allSharedProducersMap, new size {}",
                        allSharedProducersMap.size());
            }
        }
    }
Class to provide shared {@link KafkaProducer} instances wrapped inside a {@link SharedKafkaProducer}.
We want one {@link KafkaProducer} per {@link KafkaConfigDoc}, however the config in a {@link KafkaConfigDoc}
can change at runtime so on each request for a {@link SharedKafkaProducer} we need to check if the
{@link KafkaConfigDoc} has changed since the time we created it. New calls to
{@link KafkaProducerFactory#getSharedProducer(DocRef)} will always get a {@link SharedKafkaProducer} for the
latest config. {@link KafkaProducer}
stroom-kafka/stroom-kafka-impl/src/main/java/stroom/kafka/impl/KafkaProducerFactoryImpl.java