How to programmatically stop RabbitListener in Micronaut

299 Views Asked by At

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?

0

There are 0 best solutions below