Slow MQ Rabbit Delivery Speed

I am using Rabbit MQ for my application. Sometimes I have to stop my customers due to maintenance. Thus, thousands of messages are expected in the queue. After rebooting my consumers, the message delivery speed is high (500-600 messages per second). At the same time, one of my consumers cannot process messages and break up the server.

In the future I will change the consumer code, but now I need a fast soluton.

So, is there a way to slow down the delivery speed? I tried the basicQos method, but that did not work.

Note. I use Java for consumers.

+4
source share
1 answer
channel.basicConsume(queueName, false, consumer); channel.basicQos(50); consumer.getChannel().basicAck(delivery.getEnvelope().getDeliveryTag(), false); 

The first two lines make automatic confirmation false and set a delivery limit. The third line confirms the message after processing the message. This solves my problem. When auto-confirmation is true, the consumer receives messages from the queue, even if the processing of previous messages is not completed. This leads to memory problems and server failure.

+4
source

Source: https://habr.com/ru/post/1446878/


All Articles