1

I'm using spring-cloud-starter-stream-kafka to create a Kafka consumer binding and I've configured spring.cloud.stream.bindings.input.consumer.autoStartup to false

(https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/2.2.0.RELEASE/spring-cloud-stream.html#_consumer_properties).

I want to know what I have to inject at which time to start the binder (for example through a configuration which is enabled by property). I was not able to find any documentation about this.

Thanks.

Chr3is
  • 387
  • 5
  • 21

1 Answers1

2

Use the BindingsEndpoint bean to change the state.

See my answer to this question.

Currently, the actuator has to be on the class path.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • 1
    Thanks that worked! Wasn't sure if the BindingsEndpoint was the correct Bean because of the actuator reference. It may be useful to mention the BindingsEndpoint class in the docs and reference the BindingsEndpoint in the Doc for the autoStartup property. The ApplicationRunner Interface was important too, with @PostConstruct or something similar in a configuration class the invoction of the BindingsEndpoint would be to early. – Chr3is Jun 26 '20 at 11:29
  • 2
    Yes; post construct is too early - there is an [open issue](https://github.com/spring-cloud/spring-cloud-stream/issues/1907) to decouple this functionality from the actuator. – Gary Russell Jun 26 '20 at 13:39