Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push messages from unacked to ready, rabbitmq

RabbitMq is used in our application There are hundreds of messeges accumulated in time, in unacked state for couple of queues, and TTLs isn't working because of several unexpected shutdowns when the listener wasn't alive .

Now for business reason I cant just empty the queue. I want to push the unacked messages manually to ready state.

Is there any ??

Thanks !

like image 329
user3123372 Avatar asked Dec 02 '16 11:12

user3123372


2 Answers

there are 2 ways to move a message from unack'd to ready:

1) ack the message from your consumer

2) shut down the consumer that is holding them open

most likely, option #1 is not really an option. when a message gets stuck in unack'd, it's usually because the consumer lost track of the message and can't ack it anymore.

this typically leaves #2: you'll need to shut down all consumers that had previously been attached to that queue. when a message is unack'd and the consumer drops, RMQ will push the message back into ready.

if you shut down your consumers and restarting them puts the messages back into unack'd state, then you need to figure out what's causing the error in your consumer, fix the code and restart it again.

like image 100
Derick Bailey Avatar answered Oct 01 '22 15:10

Derick Bailey


Another way would be to simply restart the rabbitmq instance.

/etc/init.d/rabbitmq-server restart
like image 30
Barrie Jarman Avatar answered Oct 01 '22 15:10

Barrie Jarman