Skip to content

contextRefreshed in KafkaListenerEndpointRegistry seems useLess #2315

Closed
@youngkangrui

Description

@youngkangrui

version 2.8.6

Describe the bug
if set autoStartUp = false ,eg @KafkaListener(autoStartUp="false"),i find container do not start up even spring context has started,
but in the code,container starts depending on either contextRereshed or autoStartUp,so i think if context has started, container should start too , even if autoStartUp=false

To Reproduce

public class TestListener {
    @KafkaListener(id="id1",topics = {"tp"},groupId = "consumerGroupId",autoStartup = "false")
    public void Listen(String info){
        System.out.println(info);
    }
}

ConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class, args);
		KafkaListenerEndpointRegistry registry = (KafkaListenerEndpointRegistry)context.getBean("org.springframework.kafka.config.internalKafkaListenerEndpointRegistry");
		MessageListenerContainer id1 = registry.getListenerContainer("id1");
		System.out.println(id1.isRunning());

Expected behavior
i think if context has started, container should start too , even if autoStartUp=false , otherwise what the use of contextRefreshed in KafkaListenerEndpointRegistry?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions