Package org.springframework.kafka.event
Class ListenerContainerIdleEvent
- java.lang.Object
-
- java.util.EventObject
-
- org.springframework.context.ApplicationEvent
-
- org.springframework.kafka.event.KafkaEvent
-
- org.springframework.kafka.event.ListenerContainerIdleEvent
-
- All Implemented Interfaces:
java.io.Serializable
public class ListenerContainerIdleEvent extends KafkaEvent
An event that is emitted when a container is idle if the container is configured to do so.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ListenerContainerIdleEvent(java.lang.Object source, java.lang.Object container, long idleTime, java.lang.String id, java.util.Collection<org.apache.kafka.common.TopicPartition> topicPartitions, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, boolean paused)
Construct an instance with the provided arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.kafka.clients.consumer.Consumer<?,?>
getConsumer()
Retrieve the consumer.long
getIdleTime()
How long the container has been idle.java.lang.String
getListenerId()
The id of the listener (if@KafkaListener
) or the container bean name.java.util.Collection<org.apache.kafka.common.TopicPartition>
getTopicPartitions()
The TopicPartitions the container is listening to.boolean
isPaused()
Return true if the consumer was paused at the time the idle event was published.java.lang.String
toString()
-
Methods inherited from class org.springframework.kafka.event.KafkaEvent
getContainer, getSource
-
-
-
-
Constructor Detail
-
ListenerContainerIdleEvent
public ListenerContainerIdleEvent(java.lang.Object source, java.lang.Object container, long idleTime, java.lang.String id, java.util.Collection<org.apache.kafka.common.TopicPartition> topicPartitions, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, boolean paused)
Construct an instance with the provided arguments.- Parameters:
source
- the container instance that generated the event.container
- the container or the parent container if the container is a child.idleTime
- the idle time.id
- the container id.topicPartitions
- the topics/partitions currently assigned.consumer
- the consumer.paused
- true if the consumer is paused.- Since:
- 2.2.1
-
-
Method Detail
-
getIdleTime
public long getIdleTime()
How long the container has been idle.- Returns:
- the time in milliseconds.
-
getTopicPartitions
public java.util.Collection<org.apache.kafka.common.TopicPartition> getTopicPartitions()
The TopicPartitions the container is listening to.- Returns:
- the TopicPartition list.
-
getListenerId
public java.lang.String getListenerId()
The id of the listener (if@KafkaListener
) or the container bean name.- Returns:
- the id.
-
getConsumer
public org.apache.kafka.clients.consumer.Consumer<?,?> getConsumer()
Retrieve the consumer. Only populated if the listener is consumer-aware. Allows the listener to resume a paused consumer.- Returns:
- the consumer.
- Since:
- 2.0
-
isPaused
public boolean isPaused()
Return true if the consumer was paused at the time the idle event was published.- Returns:
- paused.
- Since:
- 2.1.5
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.EventObject
-
-