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:
Serializable
An event that is emitted when a container is idle if the container
is configured to do so.
- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionListenerContainerIdleEvent
(Object source, Object container, long idleTime, String id, 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
Modifier and TypeMethodDescriptionorg.apache.kafka.clients.consumer.Consumer<?,
?> Retrieve the consumer.long
How long the container has been idle.The id of the listener (if@KafkaListener
) or the container bean name.Collection<org.apache.kafka.common.TopicPartition>
The TopicPartitions the container is listening to.boolean
isPaused()
Return true if the consumer was paused at the time the idle event was published.toString()
Methods inherited from class org.springframework.kafka.event.KafkaEvent
getContainer, getSource
Methods inherited from class org.springframework.context.ApplicationEvent
getTimestamp
Methods inherited from class java.util.EventObject
getSource
-
Constructor Details
-
ListenerContainerIdleEvent
public ListenerContainerIdleEvent(Object source, Object container, long idleTime, String id, 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 Details
-
getIdleTime
public long getIdleTime()How long the container has been idle.- Returns:
- the time in milliseconds.
-
getTopicPartitions
The TopicPartitions the container is listening to.- Returns:
- the TopicPartition list.
-
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
- Overrides:
toString
in classEventObject
-