This content has been marked as final.
Show 2 replies
-
1. Re: Java API to get JBoss message queue information
jbertram Sep 10, 2012 5:38 PM (in response to jmsdebug)The simplest way would be to query the MBean for the particular destination you care about. You can get an administrative view of the relevant MBean by using the JMX Console. Once you identify the properties you want you simply get those with your remote MBean client.
-
2. Re: Java API to get JBoss message queue information
jmsdebug Sep 10, 2012 6:23 PM (in response to jbertram)thanks Justin
https://community.jboss.org/wiki/HowDoIGetRemoteAccessToMyMBean
code from above link
Using the RMIAdaptor (weakly typed interface)
The RMIAdaptor provides a remote view of the MBeanServer Note: Use the MBeanServerConnection interface rather than RMIAdaptor on the most recent versions of JBoss. RMIAdaptor should not be used in version 6.0 (M3) or greater (you must use MBeanServerConnection).
//import org.jboss.jmx.adapter.rmi.RMIAdaptor; import javax.management.MBeanServerConnection; public void doSomething() throws Exception { InitialContext ctx = new InitialContext(); // From jndi.properties //RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor"); MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor"); System.out.println(server.getAttribute(new ObjectName("MyDomain:key=property"), "AnAttribute")); server.invoke(new ObjectName("MyDomain:key=property"), "doSomething", new Object[0], new String[0]); } // For AS 6.0 (M3) or greater, use the following example import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; public void doSomething() throws Exception { String serverURL = "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi" String username = null; String password = null; HashMap env = new HashMap(); if (username != null && password != null) { String[] creds = new String[2]; creds[0] = username; creds[1] = password; env.put(JMXConnector.CREDENTIALS, creds); } JMXServiceURL url = new JMXServiceURL(serverURL); JMXConnector jmxc = JMXConnectorFactory.connect(url, env); // Remember to call jmxc.close() when you are done with server connection. MbeanServerConnection server = jmxc.getMBeanServerConnection(); System.out.println(server.getAttribute(new ObjectName("MyDomain:key=property"), "AnAttribute")); server.invoke(new ObjectName("MyDomain:key=property"), "doSomething", new Object[0], new String[0]); }