Search code examples
spring-batchspring-rabbit

What is the simplest way to pause spring boot rabbit mq consumer?


Is there a simple a simple way to pause the spirng boot AMPQ and resume is after some time??

i'm using spring boot verison 2.6


Solution

  • If it is a @RabbitListener method, give it an id attribute and stop/start it via the RabbitListenerEndpointRegistry @Bean.

    registry.getListenerContainer("myListenerId").stop();
    

    If you created the listener container yourself then it can be stopped and started directly.