使用Spring Data Stream,如何从队列开始读取并按需停止读取?
我想要这样的事情:
@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?
}
}
无法通过静态方法完成;自动连接BindingsEndpoint
并使用changeState()
方法。
请参阅我对this question的回答。