K - the key type.V - the value type.public abstract class AbstractMessageListenerContainer<K,V> extends java.lang.Object implements GenericMessageListenerContainer<K,V>, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationEventPublisherAware
MessageListenerContainer.| Modifier and Type | Field and Description |
|---|---|
protected ConsumerFactory<K,V> |
consumerFactory |
static int |
DEFAULT_PHASE
The default
SmartLifecycle phase for listener
containers 2147483547. |
protected org.apache.commons.logging.Log |
logger |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMessageListenerContainer(ConsumerFactory<? super K,? super V> consumerFactory,
ContainerProperties containerProperties)
Construct an instance with the provided factory and properties.
|
protected |
AbstractMessageListenerContainer(ContainerProperties containerProperties)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkGroupId() |
protected void |
checkTopics() |
protected org.apache.kafka.clients.consumer.ConsumerRebalanceListener |
createSimpleLoggingConsumerRebalanceListener()
Return default implementation of
ConsumerRebalanceListener instance. |
protected abstract void |
doStart() |
protected abstract void |
doStop(java.lang.Runnable callback) |
protected AfterRollbackProcessor<? super K,? super V> |
getAfterRollbackProcessor() |
org.springframework.context.ApplicationEventPublisher |
getApplicationEventPublisher() |
java.lang.String |
getBeanName() |
ContainerProperties |
getContainerProperties()
Return the container properties for this container.
|
protected GenericErrorHandler<?> |
getGenericErrorHandler()
Get the configured error handler.
|
java.lang.String |
getGroupId()
Return the
group.id property for this container whether specifically set on the
container or via a consumer property on the consumer factory. |
java.lang.String |
getListenerId()
The 'id' attribute of a
@KafkaListener or the bean name for spring-managed
containers. |
int |
getPhase() |
protected RecordInterceptor<K,V> |
getRecordInterceptor() |
boolean |
isAutoStartup() |
protected boolean |
isPaused() |
boolean |
isPauseRequested()
Return true if
MessageListenerContainer.pause() has been called; the container might not have actually
paused yet. |
boolean |
isRunning() |
protected AbstractMessageListenerContainer<?,?> |
parentOrThis()
Return this or a parent container if this has a parent.
|
void |
pause()
Pause this container before the next poll().
|
protected void |
publishContainerStoppedEvent() |
void |
resume()
Resume this container, if paused, after the next poll().
|
void |
setAfterRollbackProcessor(AfterRollbackProcessor<? super K,? super V> afterRollbackProcessor)
Set a processor to perform seeks on unprocessed records after a rollback.
|
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
void |
setAutoStartup(boolean autoStartup)
Set the autoStartup.
|
void |
setBatchErrorHandler(BatchErrorHandler errorHandler)
Set the batch error handler to call when the listener throws an exception.
|
void |
setBeanName(java.lang.String name) |
void |
setErrorHandler(ErrorHandler errorHandler)
Set the error handler to call when the listener throws an exception.
|
void |
setGenericErrorHandler(GenericErrorHandler<?> errorHandler)
Set the error handler to call when the listener throws an exception.
|
void |
setPhase(int phase) |
void |
setRecordInterceptor(RecordInterceptor<K,V> recordInterceptor)
Set an interceptor to be called before calling the listener.
|
protected void |
setRunning(boolean running) |
void |
setupMessageListener(java.lang.Object messageListener)
Setup the message listener to use.
|
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAssignedPartitions, isContainerPaused, metricspublic static final int DEFAULT_PHASE
SmartLifecycle phase for listener
containers 2147483547.protected final org.apache.commons.logging.Log logger
protected final ConsumerFactory<K,V> consumerFactory
@Deprecated protected AbstractMessageListenerContainer(ContainerProperties containerProperties)
AbstractMessageListenerContainer(ConsumerFactory, ContainerProperties).containerProperties - the properties.protected AbstractMessageListenerContainer(ConsumerFactory<? super K,? super V> consumerFactory, ContainerProperties containerProperties)
consumerFactory - the factory.containerProperties - the properties.public void setBeanName(java.lang.String name)
setBeanName in interface org.springframework.beans.factory.BeanNameAwarepublic java.lang.String getBeanName()
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAwarepublic org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()
public void setErrorHandler(ErrorHandler errorHandler)
errorHandler - the error handler.public void setGenericErrorHandler(GenericErrorHandler<?> errorHandler)
errorHandler - the error handler.public void setBatchErrorHandler(BatchErrorHandler errorHandler)
errorHandler - the error handler.protected GenericErrorHandler<?> getGenericErrorHandler()
public boolean isAutoStartup()
isAutoStartup in interface org.springframework.context.SmartLifecyclepublic void setAutoStartup(boolean autoStartup)
MessageListenerContainersetAutoStartup in interface MessageListenerContainerautoStartup - the autoStartup to set.SmartLifecycleprotected void setRunning(boolean running)
public boolean isRunning()
isRunning in interface org.springframework.context.Lifecycleprotected boolean isPaused()
public boolean isPauseRequested()
MessageListenerContainerMessageListenerContainer.pause() has been called; the container might not have actually
paused yet.isPauseRequested in interface MessageListenerContainerpublic void setPhase(int phase)
public int getPhase()
getPhase in interface org.springframework.context.PhasedgetPhase in interface org.springframework.context.SmartLifecycleprotected AfterRollbackProcessor<? super K,? super V> getAfterRollbackProcessor()
public void setAfterRollbackProcessor(AfterRollbackProcessor<? super K,? super V> afterRollbackProcessor)
afterRollbackProcessor - the processor.public ContainerProperties getContainerProperties()
MessageListenerContainergetContainerProperties in interface MessageListenerContainerpublic java.lang.String getGroupId()
MessageListenerContainergroup.id property for this container whether specifically set on the
container or via a consumer property on the consumer factory.getGroupId in interface MessageListenerContainer@Nullable public java.lang.String getListenerId()
MessageListenerContainer@KafkaListener or the bean name for spring-managed
containers.getListenerId in interface MessageListenerContainerprotected RecordInterceptor<K,V> getRecordInterceptor()
public void setRecordInterceptor(RecordInterceptor<K,V> recordInterceptor)
recordInterceptor - the interceptor.public void setupMessageListener(java.lang.Object messageListener)
MessageListenerContainerIllegalArgumentException
if that message listener type is not supported.setupMessageListener in interface MessageListenerContainermessageListener - the object to wrapped to the MessageListener.public final void start()
start in interface org.springframework.context.Lifecycleprotected void checkTopics()
public void checkGroupId()
protected abstract void doStart()
public final void stop()
stop in interface org.springframework.context.Lifecyclepublic void pause()
MessageListenerContainerpause in interface MessageListenerContainerpublic void resume()
MessageListenerContainerresume in interface MessageListenerContainerpublic void stop(java.lang.Runnable callback)
stop in interface org.springframework.context.SmartLifecycleprotected abstract void doStop(java.lang.Runnable callback)
protected final org.apache.kafka.clients.consumer.ConsumerRebalanceListener createSimpleLoggingConsumerRebalanceListener()
ConsumerRebalanceListener instance.ConsumerRebalanceListener currently assigned to this container.protected void publishContainerStoppedEvent()
protected AbstractMessageListenerContainer<?,?> parentOrThis()