Last active
December 27, 2019 16:19
-
-
Save noonedeadpunk/4a22b2dcc3b22fcc295445ed18c66247 to your computer and use it in GitHub Desktop.
Drop rabbitmq queues without consumers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Classis FOR ### | |
vhost="/"; for queue in `rabbitmqctl list_queues name consumers -p $vhost --formatter csv`; do name=`echo $queue | cut -d "," -f 1 | tr -d '"'`; consumers=`echo $queue | cut -d "," -f 2 | tr -d '"'`; if [[ "$consumers" == "0" ]]; then rabbitmqctl delete_queue $name -p $vhost ; fi; done | |
### Faster XARGS ### | |
vhost="/"; rabbitmqctl list_queues name consumers -p $vhost --formatter csv | xargs -P 20 -I {} env vhost=$vhost bash -c 'name=$(echo {} | cut -d "," -f 1); consumers=$(echo {} | cut -d "," -f 2); if [[ "$consumers" != "0" ]]; then rabbitmqctl delete_queue $name -p $vhost ; fi' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment