public class KafkaListenerEndpointRegistry
extends java.lang.Object
implements org.springframework.beans.factory.DisposableBean, org.springframework.context.SmartLifecycle, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
MessageListenerContainer
instances for the
registered endpoints. Also manages the
lifecycle of the listener containers, in particular within the lifecycle
of the application context.
Contrary to MessageListenerContainer
s created manually, listener
containers managed by registry are not beans in the application context and
are not candidates for autowiring. Use getListenerContainers()
if
you need to access this registry's listener containers for management purposes.
If you need to access to a specific message listener container, use
getListenerContainer(String)
with the id of the endpoint.
KafkaListenerEndpoint
,
MessageListenerContainer
,
KafkaListenerContainerFactory
Modifier and Type | Field and Description |
---|---|
protected org.springframework.core.log.LogAccessor |
logger |
Constructor and Description |
---|
KafkaListenerEndpointRegistry() |
Modifier and Type | Method and Description |
---|---|
protected MessageListenerContainer |
createListenerContainer(KafkaListenerEndpoint endpoint,
KafkaListenerContainerFactory<?> factory)
Create and start a new
MessageListenerContainer using the specified factory. |
void |
destroy() |
java.util.Collection<MessageListenerContainer> |
getAllListenerContainers()
Return all
MessageListenerContainer instances including those managed by
this registry and those declared as beans in the application context. |
MessageListenerContainer |
getListenerContainer(java.lang.String id)
Return the
MessageListenerContainer with the specified id or
null if no such container exists. |
java.util.Set<java.lang.String> |
getListenerContainerIds()
Return the ids of the managed
MessageListenerContainer instance(s). |
java.util.Collection<MessageListenerContainer> |
getListenerContainers()
Return the managed
MessageListenerContainer instance(s). |
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
void |
registerListenerContainer(KafkaListenerEndpoint endpoint,
KafkaListenerContainerFactory<?> factory)
Create a message listener container for the given
KafkaListenerEndpoint . |
void |
registerListenerContainer(KafkaListenerEndpoint endpoint,
KafkaListenerContainerFactory<?> factory,
boolean startImmediately)
Create a message listener container for the given
KafkaListenerEndpoint . |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public MessageListenerContainer getListenerContainer(java.lang.String id)
MessageListenerContainer
with the specified id or
null
if no such container exists.id
- the id of the containernull
if no container with that id existsKafkaListenerEndpoint.getId()
,
getListenerContainerIds()
public java.util.Set<java.lang.String> getListenerContainerIds()
MessageListenerContainer
instance(s).getListenerContainer(String)
public java.util.Collection<MessageListenerContainer> getListenerContainers()
MessageListenerContainer
instance(s).MessageListenerContainer
instance(s).getAllListenerContainers()
public java.util.Collection<MessageListenerContainer> getAllListenerContainers()
MessageListenerContainer
instances including those managed by
this registry and those declared as beans in the application context.
Prototype-scoped containers will be included. Lazy beans that have not yet been
created will not be initialized by a call to this method.MessageListenerContainer
instance(s).getListenerContainers()
public void registerListenerContainer(KafkaListenerEndpoint endpoint, KafkaListenerContainerFactory<?> factory)
KafkaListenerEndpoint
.
This create the necessary infrastructure to honor that endpoint with regards to its configuration.
endpoint
- the endpoint to addfactory
- the listener factory to useregisterListenerContainer(KafkaListenerEndpoint, KafkaListenerContainerFactory, boolean)
public void registerListenerContainer(KafkaListenerEndpoint endpoint, KafkaListenerContainerFactory<?> factory, boolean startImmediately)
KafkaListenerEndpoint
.
This create the necessary infrastructure to honor that endpoint with regards to its configuration.
The startImmediately
flag determines if the container should be
started immediately.
endpoint
- the endpoint to add.factory
- the KafkaListenerContainerFactory
to use.startImmediately
- start the container immediately if necessarygetListenerContainers()
,
getListenerContainer(String)
protected MessageListenerContainer createListenerContainer(KafkaListenerEndpoint endpoint, KafkaListenerContainerFactory<?> factory)
MessageListenerContainer
using the specified factory.endpoint
- the endpoint to create a MessageListenerContainer
.factory
- the KafkaListenerContainerFactory
to use.MessageListenerContainer
.public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean
public int getPhase()
getPhase
in interface org.springframework.context.Phased
getPhase
in interface org.springframework.context.SmartLifecycle
public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public void stop(java.lang.Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent
in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>