Example usage for org.springframework.kafka.config KafkaListenerConfigUtils KAFKA_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME

List of usage examples for org.springframework.kafka.config KafkaListenerConfigUtils KAFKA_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME

Introduction

In this page you can find the example usage for org.springframework.kafka.config KafkaListenerConfigUtils KAFKA_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME.

Prototype

String KAFKA_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME

To view the source code for org.springframework.kafka.config KafkaListenerConfigUtils KAFKA_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME.

Click Source Link

Document

The bean name of the internally managed Kafka listener endpoint registry.

Usage

From source file:org.springframework.kafka.annotation.KafkaListenerAnnotationBeanPostProcessor.java

@Override
public void afterSingletonsInstantiated() {
    this.registrar.setBeanFactory(this.beanFactory);

    if (this.beanFactory instanceof ListableBeanFactory) {
        Map<String, KafkaListenerConfigurer> instances = ((ListableBeanFactory) this.beanFactory)
                .getBeansOfType(KafkaListenerConfigurer.class);
        for (KafkaListenerConfigurer configurer : instances.values()) {
            configurer.configureKafkaListeners(this.registrar);
        }//ww w  .  j ava 2  s.  c  o  m
    }

    if (this.registrar.getEndpointRegistry() == null) {
        if (this.endpointRegistry == null) {
            Assert.state(this.beanFactory != null,
                    "BeanFactory must be set to find endpoint registry by bean name");
            this.endpointRegistry = this.beanFactory.getBean(
                    KafkaListenerConfigUtils.KAFKA_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME,
                    KafkaListenerEndpointRegistry.class);
        }
        this.registrar.setEndpointRegistry(this.endpointRegistry);
    }

    if (this.containerFactoryBeanName != null) {
        this.registrar.setContainerFactoryBeanName(this.containerFactoryBeanName);
    }

    // Set the custom handler method factory once resolved by the configurer
    MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory();
    if (handlerMethodFactory != null) {
        this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory);
    }

    // Actually register all listeners
    this.registrar.afterPropertiesSet();
}