停止使用 Stream 侦听器的消息
Stop consume message for Stream listener
我正在寻找一种方法来停止使用流侦听器使用消息。
@StreamListener(MBinding.M_INPUT)
public void consumeMessage(Message<MerchantEvent> message) {
//handle when receive message
}
cloud:
stream:
bindings:
MInput:
destination: topicName
group: groupName
我用谷歌搜索了它,但现在仍然不知道如何停止消费。有知道的人吗?
您可以使用执行器来完成(参见 Binding Visualization and Control)。或者您可以以编程方式调用端点。
@SpringBootApplication
@EnableBinding(Sink.class)
public class So58795176Application {
public static void main(String[] args) {
SpringApplication.run(So58795176Application.class, args);
}
@StreamListener(Sink.INPUT)
public void listen(String in) {
System.out.println();
}
@Autowired
BindingsEndpoint endpoint;
@Bean
public ApplicationRunner runner() {
return args -> {
System.in.read();
endpoint.changeState("input", State.STOPPED);
System.in.read();
endpoint.changeState("input", State.STARTED);
};
}
}
我正在寻找一种方法来停止使用流侦听器使用消息。
@StreamListener(MBinding.M_INPUT)
public void consumeMessage(Message<MerchantEvent> message) {
//handle when receive message
}
cloud:
stream:
bindings:
MInput:
destination: topicName
group: groupName
我用谷歌搜索了它,但现在仍然不知道如何停止消费。有知道的人吗?
您可以使用执行器来完成(参见 Binding Visualization and Control)。或者您可以以编程方式调用端点。
@SpringBootApplication
@EnableBinding(Sink.class)
public class So58795176Application {
public static void main(String[] args) {
SpringApplication.run(So58795176Application.class, args);
}
@StreamListener(Sink.INPUT)
public void listen(String in) {
System.out.println();
}
@Autowired
BindingsEndpoint endpoint;
@Bean
public ApplicationRunner runner() {
return args -> {
System.in.read();
endpoint.changeState("input", State.STOPPED);
System.in.read();
endpoint.changeState("input", State.STARTED);
};
}
}