Package org.springframework.kafka.event
Class ListenerContainerPartitionIdleEvent
java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
org.springframework.kafka.event.KafkaEvent
org.springframework.kafka.event.ListenerContainerPartitionIdleEvent
- All Implemented Interfaces:
Serializable
An event that is emitted when a container partition is idle if the container
is configured to do so.
- Since:
- 2.7
- Author:
- Tomaz Fernandes
- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorsConstructorDescriptionListenerContainerPartitionIdleEvent
(Object source, Object container, long idleTime, String id, org.apache.kafka.common.TopicPartition topicPartition, 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 partition has been idle.The id of the listener (if@KafkaListener
) or the container bean name.org.apache.kafka.common.TopicPartition
The idle TopicPartition.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
-
ListenerContainerPartitionIdleEvent
public ListenerContainerPartitionIdleEvent(Object source, Object container, long idleTime, String id, org.apache.kafka.common.TopicPartition topicPartition, 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.topicPartition
- the topic/partition.consumer
- the consumer.paused
- true if the consumer partition is paused.- Since:
- 2.7
-
-
Method Details
-
getIdleTime
public long getIdleTime()How long the partition has been idle.- Returns:
- the time in milliseconds.
-
getTopicPartition
public org.apache.kafka.common.TopicPartition getTopicPartition()The idle TopicPartition.- Returns:
- the TopicPartition.
-
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
-