Skip to content

Instantly share code, notes, and snippets.

@bsingr
Last active October 29, 2021 12:10
Show Gist options
  • Save bsingr/a330af6dc0eae322117c4f35dce472e4 to your computer and use it in GitHub Desktop.
Save bsingr/a330af6dc0eae322117c4f35dce472e4 to your computer and use it in GitHub Desktop.
rabbitmq amqp delete queues
const filter = 'node.1.response.queue' // e.g. when someone used foo-foo-mq with replyQueue:true defaults
const baseUrl = 'http://rabbitmq:15762'
let pageIdx = 1
let shouldFetchAnotherPage = true
while (shouldFetchAnotherPage) {
console.log('Fetching queues page ' + pageIdx)
const queues = await (await fetch(`${baseUrl}/api/queues?page=1&page_size=500&name=${filter}&use_regex=false&pagination=true`)).json()
shouldFetchAnotherPage = queues.page_count > 1
for (const queue of queues.items) {
if (queue.name.match(new RegExp(filter))) {
await fetch(`${baseUrl}/api/queues/%2F/${queue.name}`, {
method: 'delete'
})
console.log('Deleted ' + queue.name)
}
}
pageIdx++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment