Skip to content

Instantly share code, notes, and snippets.

@asgs
Created November 29, 2018 21:06
Show Gist options
  • Save asgs/7103b03c920accfb56061e16e48d5cee to your computer and use it in GitHub Desktop.
Save asgs/7103b03c920accfb56061e16e48d5cee to your computer and use it in GitHub Desktop.
Purge the given RabbitMQ Queues
#!/bin/bash
if [ $# -lt 4 ]; then
echo "At least four arguments are required. First is the hostname, 2nd and 3rd will be the RabbitMQ console username and passsword, 4th will be the queue name. If more than one queue is to be purged, pass as many additional arguments as necessary."
exit
fi
echo "Received request to Purge the Queues - ${@:4}"
for queue_name in "${@:4}"
do
echo "Attempting to purge queue '$queue_name'"
curl -u $2:$3 -s -X DELETE http://$1:15672/api/queues/%2f/$queue_name/contents -w "Status code is %{http_code}\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment