My Spring boot application does two task
- Initialise cache
- kafka consumer
Already have a ApplicationEvent for cache initialisation and I want consumer to start listening the messages once cache initialisation is completed.
My Spring boot application does two task
Already have a ApplicationEvent for cache initialisation and I want consumer to start listening the messages once cache initialisation is completed.
If you are using @KafkaListener
, give it an id
and set autoStartup
to false
.
When you are ready, use the KafkaListenerEndpointRegistry
bean to start the container.
registry.getMessageListenerContainer("myId").start()
.
If you are using a listener container bean, set its autoStartup
to false
and start()
it when ready.