Question

when i tried to delete one queue from broker(activemq) using below code , i got error like Instancenotfound exception.code following

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection conn = jmxc.getMBeanServerConnection();

String operationName="removeQueue";
String parameter="PostWithParameter_Queue"; //am given queue name
ObjectName activeMQ = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Broker");
if(parameter != null) {
    Object[] params = {parameter};
    String[] sig = {"java.lang.String"};
    conn.invoke(activeMQ, operationName, params, sig);
} else {
    conn.invoke(activeMQ, operationName,null,null);
} 

the exact error i got shown below

   Exception in thread "main" javax.management.InstanceNotFoundException: org.apache.activemq:BrokerName=localhost,Type=Broker
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getClassLoaderFor(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getClassLoaderFor(Unknown Source)

i got this code from this below link

http://www.consulting-notes.com/2010/08/monitoring-and-managing-activemq-with.html

please go through this link if am not clear.Thanks Advance

Was it helpful?

Solution 2

i got the answer.the code follows

ObjectName activeMQ = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Broker");

In the above code i mention BrokerName's and Type's first letter is capital .but it should be small letter like

ObjectName activeMQ = new ObjectName("org.apache.activemq:brokerName=localhost,type=Broker");

OTHER TIPS

Apache ActiveMQ 5.8 has changed the MBean naming. See details at the release notes which has a table with old vs new name: http://activemq.apache.org/activemq-580-release.html

The blog with the notes you found is from 2010, so its covering an older ActiveMQ version where the MBean names hasn't changed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top