Using Spring Data Stream, How can I start reading from a queue and stop reading on demand?
I want to so something like this:
@EnableBinding(Sink.class)
public class SomeConsumer {
@StreamListener(target = Sink.INPUT)
public void receiveMsg(Message<String> message)
{
logger.info(" received new message [" + message.toString() + "] ");
}
public static void startReceiving()
{
//How to implement this logic?
}
public static void stopReceiving()
{
//How to implement this logic?
}
}
It can't be done in a static method; autowire the BindingsEndpoint
and use the changeState()
method.
See my answer to this question.