ActiveMQ: how to programmatically monitor embedded broker -


i want monitor embedded activemq 5.8 broker inside code.

  • how can done?
  • do need jmx connection? want prevent exposing jmx
  • is there way of accessing org.apache.activemq.broker.jmx beans without jmx?
  • are there hooks, listeners, events, ... can attached broker itself?
  • if bad idea, why?

you can access standard jmx mbeans within process has embedded broker without creating jmx connector expose them outside world. first need tell embedded broker enable jmx not create connector.

    brokerservice = new brokerservice();     brokerservice.setpersistent(false);     brokerservice.setadvisorysupport(false);     brokerservice.setschedulersupport(true);     brokerservice.setpopulatejmsxuserid(true);     brokerservice.setschedulersupport(true);     brokerservice.getmanagementcontext().setcreateconnector(false); 

then in code can access jms mbeans normal instance brokerviewmbean:

protected brokerviewmbean getproxytobroker() throws malformedobjectnameexception, jmsexception {     objectname brokerviewmbean = new objectname(         "org.apache.activemq:type=broker,brokername=localhost");     brokerviewmbean proxy = (brokerviewmbean) brokerservice.getmanagementcontext()             .newproxyinstance(brokerviewmbean, brokerviewmbean.class, true);     return proxy; } 

or queueviewmbean:

protected queueviewmbean getproxytoqueue(string name) throws malformedobjectnameexception, jmsexception {     objectname queueviewmbeanname = new objectname("org.apache.activemq:type=broker,brokername=localhost,destinationtype=queue,destinationname="+name);     queueviewmbean proxy = (queueviewmbean) brokerservice.getmanagementcontext()             .newproxyinstance(queueviewmbeanname, queueviewmbean.class, true);     return proxy; } 

and topicviewmbean.

protected topicviewmbean getproxytotopic(string name) throws malformedobjectnameexception, jmsexception {     objectname topicviewmbeanname = new objectname("org.apache.activemq:type=broker,brokername=localhost,destinationtype=topic,destinationname="+name);     topicviewmbean proxy = (topicviewmbean) brokerservice.getmanagementcontext()             .newproxyinstance(topicviewmbeanname, topicviewmbean.class, true);     return proxy; } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -