Below is how we are publishing messages to topic,
for(int i=0;i<=10000;i++){
send("topic_name", "message");
}
We have stream listener as below for above topic,
@StreamListener("topic_name")
public void process(KStream<String, String> inputKStream) {
//processing of messages
}
Now the requirement is we need to stop processing of messages when API is triggered.
For that we have a controller as below,
@Autowired
private CustomBindingEndpoint endpoint;
@PutMapping(value = "stop", produces = APPLICATION_JSON_UTF8_VALUE)
public void stopProcess() {
endpoint.changeState("topic_name", State.STOPPED);
}
The CustomBindingEndpoint.java is same as https://github.com/spring-cloud/spring-cloud-stream/issues/1650#issuecomment-476626008
Once we trigger this API we expect the above StreamListener("topic_name") should get stop(further consuming has to be stopped)
But once we trigger, even though binding.stop() is invoked for "topic_name" the consumer still consumes messages.
I understand that binding.stop() will stop the consumer from consuming message. Please correct if i am wrong. kindly suggest how we can achieve this.