Aditya Gupta
Aditya Gupta

Reputation: 3

Run a method before starting spring kafka-consumer

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

Upvotes: 0

Views: 1033

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121202

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

Upvotes: 2

Related Questions