问题
I'm using Spring Cloud Stream Kafka, but I have a particular service that has a complex start-up dependency (long-running) that can be rather fragile so would like to delay Kafka (consumer) binding until successful initialization is confirmed.
How can I achieve this?
回答1:
It's not currently possible with Spring Cloud Stream; you can do it by using Spring Kafka directly (e.g. @KafkaListener) and set the container factory's autoStartup to false. Or with Spring Integration Kafka and do the same for the inbound channel adapter.
You could do it with Spring Cloud Stream by loading the @StreamListener into a child boot application instead of the main one.
来源:https://stackoverflow.com/questions/50351490/kafka-delay-binding-until-complex-service-initialisation-has-completed