Skip to content

alwaysStartAfterRefresh seems not work #2316

@youngkangrui

Description

@youngkangrui

contextRereshed in KafkaListenerEndPointRegistry is set to true only if received ContextRefreshEvent, but in Spring SmartLifeCycle is triggered before ContextFreshEvent is sended out , so when smartLIfeCycle wants to start the containers, contextRefreshed will always be false, so my question is adding alwaysStartAfterRefresh this way ( #2301 ) will not start the containers even if context refreshed.

using 2.8.7 ,following code's output is still false, while true is expected

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());

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