My application is listening to several topics. Some of them are compacted topics used to load in memory some data.
I wanted to load first thoses data, so I used a SmartLifecycle to manually start those container before the other containers.
It's working great, but for simplicity, I tried to use a containerGroup
@KafkaListener(id = "myId", containerGroup = "compacted", ...)
Then in the SmartLifecycle bean I used :
Collection<MessageListenerContainer> compactedListenerContainers = applicationContext.getBean("compacted", Collection.class);
But once I do that, after the "start" method is finished, the other containers are never started.
If I replace this line by :
Collection<MessageListenerContainer> compactedListenerContainers = Arrays.asList(registry.getListenerContainer("myId"));
Any idea why getting the bean for a containerGroup prevent all other listener to work ? Knowing that all other @KafkaListeners are just defined by :
@KafkaListener(topics = "myTopic")
After further investigations, the problem is related to the KafkaListenerEndpointRegistry.
If the SmartLifeCycle bean is created with "KafkaListenerEndpointRegistry" as a dependency the application is working. Even if I'm not using the registry at all.
But if the SmartLifeCycle bean is created without this registry, the application fail.