Dev/jmx

From CubeiaWiki

Jump to: navigation, search

To connect to a running Firbase via JMX from another Java process you need to do the following.

Include firebase-jmx artifact.

<dependency>
   <groupId>com.cubeia.firebase</groupId>
   <artifactId>firebase-jmx</artifactId>
   <version>1.9.4-CE</version>
   <scope>provided</scope>
</dependency>


Then create a connection to the remote Firebase JMX Server

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:8999/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

Then you can create proxy mBeans that you can invoke methods on directly. Remember that all methods call are done remotely so they may take time to execute and can fail mid-call. Below is an example of getting the StateClientRegistryMBean proxy.

ObjectName clientRegistryName = new ObjectName("com.cubeia.firebase.clients:type=ClientRegistry");
StateClientRegistryMBean clientRegistry = JMX.newMBeanProxy(mbsc, clientRegistryName, StateClientRegistryMBean.class, true);

You can read more about what mBeans and methods are exposed in the Firebase JMX Documentation found here: http://cubeia.org/index.php/firebase/documentation

Personal tools