0

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

Ben Chan
  • 615
  • 8
  • 11
L.Kroos
  • 1
  • 3
  • https://stackoverflow.com/questions/58795176/stop-consume-message-for-stream-listener – JCompetence May 30 '23 at 06:50
  • You can't, simply because StreamListener and annotation-based programming model has been deprecated for over 4 years and have been removed. You must be using some older version of s-c-stream. Please upgrade and use the new functional model - https://docs.spring.io/spring-cloud-stream/docs/3.2.8/reference/html/spring-cloud-stream.html#_producing_and_consuming_messages – Oleg Zhurakousky May 30 '23 at 13:13

0 Answers0