Interface MessageListenerContainer
-
- All Superinterfaces:
org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
- All Known Subinterfaces:
GenericMessageListenerContainer<K,V>
- All Known Implementing Classes:
AbstractMessageListenerContainer
,ConcurrentMessageListenerContainer
,KafkaMessageListenerContainer
public interface MessageListenerContainer extends org.springframework.context.SmartLifecycle
Internal abstraction used by the framework representing a message listener container. Not meant to be implemented externally.- Author:
- Stephane Nicoll, Gary Russell, Vladimir Tsanev, Tomaz Fernandes
-
-
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 thegroup.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
isChildRunning()
If this container has child containers, return true if at least one child is running.default boolean
isContainerPaused()
Return true ifpause()
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 ifpause()
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 byclient-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.
-
-
-
Method Detail
-
setupMessageListener
void setupMessageListener(java.lang.Object messageListener)
Setup the message listener to use. Throws anIllegalArgumentException
if that message listener type is not supported.- Parameters:
messageListener
- theobject
to wrapped to theMessageListener
.
-
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 byclient-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 ifpause()
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 ifpause()
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
@Nullable default java.lang.String getGroupId()
Return thegroup.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
-
isChildRunning
default boolean isChildRunning()
If this container has child containers, return true if at least one child is running. If there are not child containers, returnsLifecycle.isRunning()
.- Returns:
- true if a child is running.
- Since:
- 2.7.3
-
-