Class ConcurrentMessageListenerContainer<K,​V>

  • Type Parameters:
    K - the key type.
    V - the value type.
    All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, GenericMessageListenerContainer<K,​V>, MessageListenerContainer

    public class ConcurrentMessageListenerContainer<K,​V>
    extends AbstractMessageListenerContainer<K,​V>
    Creates 1 or more KafkaMessageListenerContainers based on concurrency. If the ContainerProperties is configured with TopicPartitions, the TopicPartitions are distributed evenly across the instances.
    Marius Bogoevici, Gary Russell, Murali Reddy, Jerome Mirc, Artem Bilan, Vladimir Tsanev
    • Constructor Detail

      • ConcurrentMessageListenerContainer

        public ConcurrentMessageListenerContainer​(ConsumerFactory<? super K,​? super V> consumerFactory,
                                                  ContainerProperties containerProperties)
        Construct an instance with the supplied configuration properties. The topic partitions are distributed evenly across the delegate KafkaMessageListenerContainers.
        consumerFactory - the consumer factory.
        containerProperties - the container properties.
    • Method Detail

      • getConcurrency

        public int getConcurrency()
      • setConcurrency

        public void setConcurrency​(int concurrency)
        The maximum number of concurrent KafkaMessageListenerContainers running. Messages from within the same partition will be processed sequentially.
        concurrency - the concurrency.
      • setAlwaysClientIdSuffix

        public void setAlwaysClientIdSuffix​(boolean alwaysClientIdSuffix)
        Set to false to suppress adding a suffix to the child container's when the concurrency is only 1.
        alwaysClientIdSuffix - false to suppress, true (default) to include.
      • getAssignedPartitions

        public java.util.Collection<org.apache.kafka.common.TopicPartition> getAssignedPartitions()
        Description copied from interface: MessageListenerContainer
        Return the assigned topics/partitions for this container.
        the topics/partitions.
      • getAssignmentsByClientId

        public java.util.Map<java.lang.String,​java.util.Collection<org.apache.kafka.common.TopicPartition>> getAssignmentsByClientId()
        Description copied from interface: MessageListenerContainer
        Return the assigned topics/partitions for this container, by
        the topics/partitions.
      • isContainerPaused

        public boolean isContainerPaused()
        Description copied from interface: MessageListenerContainer
        Return true if MessageListenerContainer.pause() has been called; and all consumers in this container have actually paused.
        true if the container is paused.
      • metrics

        public java.util.Map<java.lang.String,​java.util.Map<org.apache.kafka.common.MetricName,​? extends org.apache.kafka.common.Metric>> metrics()
        Description copied from interface: MessageListenerContainer
        Return metrics kept by this container's consumer(s), grouped by client-id.
        the consumer(s) metrics grouped by client-id
        See Also:
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object