Created
October 2, 2013 03:16
-
-
Save brettporter/6788653 to your computer and use it in GitHub Desktop.
Remove a set of queues from ActiveMQ
This file contains hidden or 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
#!/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