Skip to content

Instantly share code, notes, and snippets.

@jsvd
Created May 31, 2011 22:30
Show Gist options
  • Select an option

  • Save jsvd/1001426 to your computer and use it in GitHub Desktop.

Select an option

Save jsvd/1001426 to your computer and use it in GitHub Desktop.
restart subscription connection if dequeue lag behind enqueue
require 'rubygems'
require 'jmx4r'
JMX::MBean.establish_connection :host => "localhost", :port => 9999, :username => "pwd", :password => "pwd"
JMX::MBean.find_all_by_name("org.apache.activemq:BrokerName=inner-broker,Type=Subscription,persistentMode=Non-Durable,destinationType=Topic,destinationName=pulso.>,*").each do |sub|
next unless sub.enqueue_counter - sub.dequeue_counter > 100
conn = JMX::MBean.find_all_by_name("org.apache.activemq:BrokerName=inner-broker,Type=Connection,ConnectorName=inner-openwire,Connection=ID_#{conn_id.split(":")[1][0...-2]}*").first
conn.stop
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment