Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when rabbitmq delete message from queue?

Tags:

rabbitmq

First of all i declare exchange,queue and bind them togerther. i basicPublish a message to this queue, so there are one message you in the queue. At this time i start my consumer program(with autoAck = true) and debug it, when i run to basicConsume(xxx), the message was lost! In my opinion consumer will send basic.ack to broker when it run to the method nextDelivery(), but in fact when i will declare a consumer, the message in queue is taken. why? Can someone tell me when rabbitmq delete message from queue? after the method basicConsume() or nextDelivery()??? thx~~~

like image 288
chris.lin Avatar asked Sep 23 '15 11:09

chris.lin


People also ask

Does RabbitMQ delete messages?

Messages should not stay in queues, this is not the main purpose of RabbitMQ to store messages, it's more to deliver messages. So having many undelivered messages (so you need to delete one of them) is not a good thing. RabbitMQ does not have an API to delete a specific message within a queue.

How long do messages stay in RabbitMQ?

In standard queues, messages are retained for at least 72 hours and will be deleted 72 hours later.

What does purge messages do in RabbitMQ?

The main purpose of RabbitMQ is not to store messages in Queues. Rather, its primary function is to deliver messages. Therefore, having so many undelivered messages is not a good thing. They need to be cleared, deleted, or purged occasionally.


1 Answers

autoAck = true

because of this

you are telling RabbitMQ to automatically acknowledge the message when it is consumed. acknowledging a message tells RabbitMQ that it has been taken care of and RabbitMQ can delete it now.

set autoAck to false if you want to manually acknowledge the message after you are done processing it.

like image 184
Derick Bailey Avatar answered Sep 30 '22 22:09

Derick Bailey