Recursively delete RabbitMQ queues using a shell script.

160 views
Skip to first unread message

Meghanand Acharekar

unread,
Oct 20, 2020, 1:18:01 PM10/20/20
to rabbitmq-users
Hi,

Looking some guidance on the following.
We are trying to delete a bulk of rabbitmq queues using a simple shell script which reads queue names one-by-one from a file or equivalent stdin & delete them using following command.

Code sample
------------------------
while read -r line; 
do 
         /usr/sbin/rabbitmqctl eval 'Q = {resource, <<"/">>, queue, <<'\"$line\"'>>}, rabbit_amqqueue:internal_delete(Q).'
done < my_input_file.txt

We see for each queue delete command it returns a "ok" message but actually the queue doesn't getting deleted at all, when we execute the same command via bash console - it works perfectly fine, just curious is there something to be considered related to the bash environment.
 
Or else would it will be recommended to use some other alternative tools which provides similar functionalities (like : rabbitmqadmin) for this.

I've tried to keep this message as concise as possible, please let me know any other information.


Michal Kuratczyk

unread,
Oct 20, 2020, 1:48:57 PM10/20/20
to rabbitm...@googlegroups.com
I'd personally use rabbitmqadmin. For example like this:

while read -r q; do rabbitmqadmin delete queue name=$q; done < list_of_queues



--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/e2151005-32ef-4f9f-b69d-db7f2249b089n%40googlegroups.com.


--
Michał
RabbitMQ team

Meghanand Acharekar

unread,
Oct 21, 2020, 2:23:26 AM10/21/20
to rabbitmq-users
Hi Michal,

Thanks for the update, I've tested this once - working as expected with any issues.
One more quick question - when we delete any queue is it necessary to unbind it from any existing exchanges - just wanted to understand when we delete any queue using this command - internally does this unbind it from exchanges prior it deletion ?

Thanks,
Meghanand

Wesley

unread,
Oct 21, 2020, 2:30:35 AM10/21/20
to Rabbitmq-Users
After deleting  you don’t need to unbind it anymore.

Regards 



Reply all
Reply to author
Forward
0 new messages