Class KafkaListenerEndpointRegistry

  • All Implemented Interfaces:
    java.util.EventListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

    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>
    Creates the necessary 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 MessageListenerContainers 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.

    Author:
    Stephane Nicoll, Juergen Hoeller, Artem Bilan, Gary Russell, Asi Bross
    See Also:
    KafkaListenerEndpoint, MessageListenerContainer, KafkaListenerContainerFactory
    • Field Detail

      • logger

        protected final org.springframework.core.log.LogAccessor logger
    • Constructor Detail

      • KafkaListenerEndpointRegistry

        public KafkaListenerEndpointRegistry()
    • Method Detail

      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
                                   throws org.springframework.beans.BeansException
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        Throws:
        org.springframework.beans.BeansException
      • getAllListenerContainers

        public java.util.Collection<MessageListenerContainer> getAllListenerContainers()
        Return all 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.
        Returns:
        the MessageListenerContainer instance(s).
        Since:
        2.2.5
        See Also:
        getListenerContainers()
      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
      • getPhase

        public int getPhase()
        Specified by:
        getPhase in interface org.springframework.context.Phased
        Specified by:
        getPhase in interface org.springframework.context.SmartLifecycle
      • isAutoStartup

        public boolean isAutoStartup()
        Specified by:
        isAutoStartup in interface org.springframework.context.SmartLifecycle
      • start

        public void start()
        Specified by:
        start in interface org.springframework.context.Lifecycle
      • stop

        public void stop()
        Specified by:
        stop in interface org.springframework.context.Lifecycle
      • stop

        public void stop​(java.lang.Runnable callback)
        Specified by:
        stop in interface org.springframework.context.SmartLifecycle
      • isRunning

        public boolean isRunning()
        Specified by:
        isRunning in interface org.springframework.context.Lifecycle
      • onApplicationEvent

        public void onApplicationEvent​(org.springframework.context.event.ContextRefreshedEvent event)
        Specified by:
        onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>