Search code examples
javaspringspring-bootspring-cloudspring-kafka

@StreamListener start to consume before ApplicationRunner run execute


We're using spring cloud for consuming messages from Kafka. Before @StreamListener start to read messages we need to make HTTP request in class implementing ApplicationRunner. In this class, we stop binding with BindingsEndpoint.changeState, send the request and then enable binding.

However, messages are consumed even before the application has started.

How do i get @StreamListener to work after ApplicationRunner?

Or maybe there are another ways to make http request before @StreamListener?


Solution

  • Set the consumer autoStartup binding property to false to prevent it starting before the runner.