0

I have a RabbitListener that looks like:

@RabbitListener
public class ProductListener {

    @Queue(value = "product", executor = "product-listener") 
    public void receive(MyType message) {
        // process message
    }
}

In certain cases, I want to shut down my application. However, before doing so I would like to stop the RabbitListner from consuming new messages and give it some time to finish the processing of already received messages.

In spring this should be possible via RabbitListenerEndpointRegistry#getListenerContainer(String) according to How to stop consuming messages with @RabbitListener and How to gracefully stop consuming messages with @RabbitListener .
I didn’t find something similar for Micronaut. Is this possible with Micronaut?

stm
  • 174
  • 1
  • 2
  • 11
  • You could try to set a value to the `rabbitmq.shutdown-timeout` in `SingleRabbitConnectionFactoryConfig` and it should stop consuming after the amout of time you provide – T.K Jul 30 '21 at 13:57
  • Do you mean I should call `SingleRabbitConnectionFactoryConfig.setShutdownTimeout(X)` ? That should be set to 10 seconds by default. – stm Jul 31 '21 at 14:32
  • And this default value isn't working for you ? – T.K Jul 31 '21 at 16:17

0 Answers0