Home > Enterprise >  Run a method before starting spring kafka-consumer
Run a method before starting spring kafka-consumer

Time:06-03

Can anyone please suggest how run a method for initializing my app before spring starts its kafka-consumer? I am using @KafkaListener annotation of spring to create a kafka consumer

CodePudding user response:

Please, give us more info what type of initialization you are looking for. The @KafkaListener can be marked with autoStartup="false". So, you are free to do whatever you need and then you call KafkaListenerEndpointRegistry for starting respective container manually: https://docs.spring.io/spring-kafka/docs/current/reference/html/#kafkalistener-lifecycle

  • Related