jboss debugg [
https://community.jboss.org/people/jmsdebug] created the discussion
"Re: Java API to get JBoss message queue information"
To view the discussion, visit:
https://community.jboss.org/message/758894#758894
--------------------------------------------------------------
thanks Justin
https://community.jboss.org/docs/DOC-9901
https://community.jboss.org/wiki/HowDoIGetRemoteAccessToMyMBean
*code from above link*
h3. Using the RMIAdaptor (weakly typed interface)
The RMIAdaptor provides a remote view of the MBeanServer Note: Use the
https://community.jboss.org/docs/DOC-12699 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]); }
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/758894#758894]
Start a new discussion in JBoss Messaging at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]