Class ShareKafkaMessageListenerContainer<K,V>
java.lang.Object
org.springframework.kafka.listener.AbstractShareKafkaMessageListenerContainer<K,V>
org.springframework.kafka.listener.ShareKafkaMessageListenerContainer<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
Aware,BeanNameAware,DisposableBean,ApplicationContextAware,ApplicationEventPublisherAware,Lifecycle,Phased,SmartLifecycle,GenericMessageListenerContainer<K,,V> MessageListenerContainer
public class ShareKafkaMessageListenerContainer<K,V>
extends AbstractShareKafkaMessageListenerContainer<K,V>
ShareKafkaMessageListenerContainer is a message listener container for Kafka's share consumer model.
This container manages a single-threaded consumer loop using a ShareConsumerFactory.
It is designed for use cases where Kafka's cooperative sharing protocol is desired, and provides a simple polling loop
with per-record dispatch and acknowledgement.
- Since:
- 4.0
- Author:
- Soby Chacko
-
Field Summary
Fields inherited from class org.springframework.kafka.listener.AbstractShareKafkaMessageListenerContainer
DEFAULT_PHASE, lifecycleLock, logger, shareConsumerFactory -
Constructor Summary
ConstructorsConstructorDescriptionShareKafkaMessageListenerContainer(ShareConsumerFactory<? super K, ? super V> shareConsumerFactory, ContainerProperties containerProperties) Construct an instance with the supplied configuration properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()protected voiddoStop()@Nullable StringGet theclient.idfor the consumer.booleanReturn true if the container is running, has never been started, or has been stopped.metrics()Return metrics kept by this container's consumer(s), grouped byclient-id.voidsetClientId(String clientId) Set theclient.idto use for the consumer.Methods inherited from class org.springframework.kafka.listener.AbstractShareKafkaMessageListenerContainer
destroy, getApplicationContext, getApplicationEventPublisher, getBeanName, getContainerProperties, getGroupId, getListenerId, getPhase, isAutoStartup, isRunning, setApplicationContext, setApplicationEventPublisher, setAutoStartup, setBeanName, setPhase, setRunning, setupMessageListener, start, stop, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.kafka.listener.MessageListenerContainer
childStarted, childStopped, enforceRebalance, getAssignedPartitions, getAssignmentsByClientId, getContainerFor, getListenerInfo, getMainListenerId, isChildRunning, isContainerPaused, isPartitionPaused, isPartitionPauseRequested, isPauseRequested, pause, pausePartition, resume, resumePartition, stopAbnormallyMethods inherited from interface org.springframework.context.SmartLifecycle
isPauseable
-
Constructor Details
-
Method Details
-
getClientId
Get theclient.idfor the consumer.- Returns:
- the client id, or null if not set
-
setClientId
Set theclient.idto use for the consumer.- Parameters:
clientId- the client id to set
-
isInExpectedState
public boolean isInExpectedState()Description copied from interface:MessageListenerContainerReturn true if the container is running, has never been started, or has been stopped.- Returns:
- true if the state is as expected.
- See Also:
-
metrics
public Map<String, Map<org.apache.kafka.common.MetricName, ? extends org.apache.kafka.common.Metric>> metrics()Description copied from interface:MessageListenerContainerReturn metrics kept by this container's consumer(s), grouped byclient-id.- Returns:
- the consumer(s) metrics grouped by
client-id - See Also:
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractShareKafkaMessageListenerContainer<K,V>
-
doStop
protected void doStop()- Specified by:
doStopin classAbstractShareKafkaMessageListenerContainer<K,V>
-