Is it any way to enable / disable @StreamListener in springboot programmatically?
I am building a Spring Boot service with capability to consume RabbitMQ message.
My code is very templatized as below.
public interface MessageSink
{
@Input("status_update")
SubscribableChannel statusChanged();
}
@EnableBinding(MessageSink.class)
@Component
@Primary
public class MyController
{
@StreamListener(value = "status_update")
public void statusChanged(Status status)
{
}
}`
But my specific request is to be able to start / stop receiving RabbitMQ message by my program.
It is not expected to start receiving rabbitmq message just once my service startup. I also want to start receiving rabbitmq message when I need and stop when it is not needed.
See my example code. I expect to start / stop receiving RabbitMQ message by my code