Skip to content

Instantly share code, notes, and snippets.

@klumsy
Created December 5, 2014 22:16
Show Gist options
  • Save klumsy/1f84fea3fb1de7a2e75b to your computer and use it in GitHub Desktop.
Save klumsy/1f84fea3fb1de7a2e75b to your computer and use it in GitHub Desktop.
Purge all messages in all RabbitMQ message queues.
$rabbitserver = 'localhost:15672'
$cred = Get-Credential
iwr -ContentType 'application/json' -Method Get -Credential $cred "http://${rabbitserver}/api/queues" | % {
ConvertFrom-Json $_.Content } | % { $_ } | ? { $_.messages -gt 0} | % {
iwr -method DELETE -Credential $cred -uri $("http://${rabbitserver}/api/queues/{0}/{1}" -f [System.Web.HttpUtility]::UrlEncode($_.vhost), $_.name)
}
iwr -Cr $cred "http://${rabbitserver}/api/queues" | % { ConvertFrom-Json $_.Content } | % { $_ } | % {iwr -me DELETE -Cr $cred $("http://${rabbitserver}/api/queues/{0}/{1}" -f [System.Web.HttpUtility]::UrlEncode($_.vhost), $_.name)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment