Search code examples
apache-kafkaspring-cloud-streamspring-cachespring-cloud-stream-binder-kafka

How to delay initialization of Spring Cloud Stream StreamListener?


I have problem with StreamListener initializing. I can not solve my problem.

I am using Spring Cloud Stream Kafka and Spring Cache in my project. Spring Cache is initialized after SmartLifeCycle's start() method. But StreamListener starts consuming data before SmartLifeCycle's start() method. Because of this I can not complete my cache initialization before StreamListener starts to consume data and this causes problem for me.

Is there any way to delay StreamListener processing or to delay StreamListener bean initializing?


Solution

  • You can set the binding's autoStartup to false and start the binding later using the BindingsEndpoint bean.

    See this answer.