Interface MessageListenerContainer

    • Field Summary

      • Fields inherited from interface org.springframework.context.SmartLifecycle

        DEFAULT_PHASE
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.util.Collection<org.apache.kafka.common.TopicPartition> getAssignedPartitions()
      Return the assigned topics/partitions for this container.
      default java.util.Map<java.lang.String,​java.util.Collection<org.apache.kafka.common.TopicPartition>> getAssignmentsByClientId()
      Return the assigned topics/partitions for this container, by client.id.
      default ContainerProperties getContainerProperties()
      Return the container properties for this container.
      default java.lang.String getGroupId()
      Return the group.id property for this container whether specifically set on the container or via a consumer property on the consumer factory.
      default java.lang.String getListenerId()
      The 'id' attribute of a @KafkaListener or the bean name for spring-managed containers.
      default boolean isContainerPaused()
      Return true if pause() has been called; and all consumers in this container have actually paused.
      default boolean isPartitionPaused​(org.apache.kafka.common.TopicPartition topicPartition)
      Whether or not this topic's partition is currently paused.
      default boolean isPartitionPauseRequested​(org.apache.kafka.common.TopicPartition topicPartition)
      Whether or not this topic's partition pause has been requested.
      default boolean isPauseRequested()
      Return true if pause() has been called; the container might not have actually paused yet.
      java.util.Map<java.lang.String,​java.util.Map<org.apache.kafka.common.MetricName,​? extends org.apache.kafka.common.Metric>> metrics()
      Return metrics kept by this container's consumer(s), grouped by client-id.
      default void pause()
      Pause this container before the next poll().
      default void pausePartition​(org.apache.kafka.common.TopicPartition topicPartition)
      Pause this partition before the next poll().
      default void resume()
      Resume this container, if paused, after the next poll().
      default void resumePartition​(org.apache.kafka.common.TopicPartition topicPartition)
      Resume this partition, if paused, after the next poll().
      default void setAutoStartup​(boolean autoStartup)
      Set the autoStartup.
      void setupMessageListener​(java.lang.Object messageListener)
      Setup the message listener to use.
      • Methods inherited from interface org.springframework.context.Lifecycle

        isRunning, start, stop
      • Methods inherited from interface org.springframework.context.SmartLifecycle

        getPhase, isAutoStartup, stop
    • Method Detail

      • setupMessageListener

        void setupMessageListener​(java.lang.Object messageListener)
        Setup the message listener to use. Throws an IllegalArgumentException if that message listener type is not supported.
        Parameters:
        messageListener - the object to wrapped to the MessageListener.
      • metrics

        java.util.Map<java.lang.String,​java.util.Map<org.apache.kafka.common.MetricName,​? extends org.apache.kafka.common.Metric>> metrics()
        Return metrics kept by this container's consumer(s), grouped by client-id.
        Returns:
        the consumer(s) metrics grouped by client-id
        Since:
        1.3
        See Also:
        Consumer.metrics()
      • getContainerProperties

        default ContainerProperties getContainerProperties()
        Return the container properties for this container.
        Returns:
        the properties.
        Since:
        2.1.3
      • getAssignedPartitions

        @Nullable
        default java.util.Collection<org.apache.kafka.common.TopicPartition> getAssignedPartitions()
        Return the assigned topics/partitions for this container.
        Returns:
        the topics/partitions.
        Since:
        2.1.3
      • getAssignmentsByClientId

        @Nullable
        default java.util.Map<java.lang.String,​java.util.Collection<org.apache.kafka.common.TopicPartition>> getAssignmentsByClientId()
        Return the assigned topics/partitions for this container, by client.id.
        Returns:
        the topics/partitions.
        Since:
        2.5
      • pause

        default void pause()
        Pause this container before the next poll(). This is a thread-safe operation, the actual pause is processed by the consumer thread.
        Since:
        2.1.3
        See Also:
        KafkaConsumer.pause(Collection)
      • resume

        default void resume()
        Resume this container, if paused, after the next poll(). This is a thread-safe operation, the actual resume is processed by the consumer thread.
        Since:
        2.1.3
        See Also:
        KafkaConsumer.resume(Collection)
      • pausePartition

        default void pausePartition​(org.apache.kafka.common.TopicPartition topicPartition)
        Pause this partition before the next poll(). This is a thread-safe operation, the actual pause is processed by the consumer thread.
        Parameters:
        topicPartition - the topicPartition to pause.
        Since:
        2.7
      • resumePartition

        default void resumePartition​(org.apache.kafka.common.TopicPartition topicPartition)
        Resume this partition, if paused, after the next poll(). This is a thread-safe operation, the actual pause is processed by the consumer thread.
        Parameters:
        topicPartition - the topicPartition to resume.
        Since:
        2.7
      • isPartitionPauseRequested

        default boolean isPartitionPauseRequested​(org.apache.kafka.common.TopicPartition topicPartition)
        Whether or not this topic's partition pause has been requested.
        Parameters:
        topicPartition - the topic partition to check
        Returns:
        true if pause for this TopicPartition has been requested
        Since:
        2.7
      • isPartitionPaused

        default boolean isPartitionPaused​(org.apache.kafka.common.TopicPartition topicPartition)
        Whether or not this topic's partition is currently paused.
        Parameters:
        topicPartition - the topic partition to check
        Returns:
        true if this partition has been paused.
        Since:
        2.7
      • isPauseRequested

        default boolean isPauseRequested()
        Return true if pause() has been called; the container might not have actually paused yet.
        Returns:
        true if pause has been requested.
        Since:
        2.1.5
      • isContainerPaused

        default boolean isContainerPaused()
        Return true if pause() has been called; and all consumers in this container have actually paused.
        Returns:
        true if the container is paused.
        Since:
        2.1.5
      • setAutoStartup

        default void setAutoStartup​(boolean autoStartup)
        Set the autoStartup.
        Parameters:
        autoStartup - the autoStartup to set.
        Since:
        2.2
        See Also:
        SmartLifecycle
      • getGroupId

        default java.lang.String getGroupId()
        Return the group.id property for this container whether specifically set on the container or via a consumer property on the consumer factory.
        Returns:
        the group id.
        Since:
        2.2.5
      • getListenerId

        @Nullable
        default java.lang.String getListenerId()
        The 'id' attribute of a @KafkaListener or the bean name for spring-managed containers.
        Returns:
        the id or bean name.
        Since:
        2.2.5