Skip to content

Instantly share code, notes, and snippets.

@brettporter
Created October 2, 2013 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettporter/6788653 to your computer and use it in GitHub Desktop.
Save brettporter/6788653 to your computer and use it in GitHub Desktop.
Remove a set of queues from ActiveMQ
#!/usr/bin/env ruby
require 'json'
require 'httparty'
credentials = {
:username => 'admin',
:password => 'admin',
}
api_url = "http://localhost:8161/api/jolokia"
broker_object_name = "org.apache.activemq:type=Broker,brokerName=localhost"
broker = JSON.parse HTTParty.get("#{api_url}/read/#{broker_object_name}", :basic_auth => credentials)
queues = broker['value']['Queues']
queues.map! { |queue|
/destinationName=([^,]+)/.match(queue['objectName'])[1]
}
# Queues to include
queues.select! { |queue| /^mcollective/.match(queue) }
# Or, some queues to exclude
# queues.reject! { |queue| /^(ActiveMQ)/.match(queue) }
puts "Removing queues:\n#{queues}"
queues.each { |queue|
HTTParty.get("#{api_url}/exec/#{broker_object_name}/removeQueue/#{queue}", :basic_auth => credentials)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment