How to get the GemFire JMX MBeans via API Outside the Distributed System
search cancel

How to get the GemFire JMX MBeans via API Outside the Distributed System

book

Article ID: 294137

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

This article explains how to get GemFire JMX MBeans via Java API.

Environment


Cause

Refer to the Java sample codes in this document to get the GemFire JMX MBeans via API. Those sample codes are only applicable to some cases to get those MBeans from GemFire member nodes in the target distributed system. You can get those MBeans from the stand alone applications (such as, your JMX monitoring tools, your GemFire client application and so on).

Resolution

Find out the JMX service URL to connect to the JMX Manager running on the GemFire distributed system. The URL format to find that is below:

service:jmx:rmi:///jndi/rmi://{jmx-manager-bind-address}:{jmx-manager-port}/jmxrmi
Specify the JMX manager's host name or IP with {jmx-manager-bind-address} and JMX manager port with {jmx-manager-port}

Find out the object name of the target MBean. Check it using jconsole and attach the jconsole to local GemFire process. To get the GatewaySenderMXBean, check the object name in the red square as below:
 

The sample code snippet in this case is below:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://192.168.100.1:1099/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
ObjectName gwSenderMBean = new ObjectName("GemFire:service=GatewaySender,gatewaySender=sender1,type=Member,member=SCache");
GatewaySenderMXBean gsmxbean = JMX.newMBeanProxy(mbsc, gwSenderMBean, GatewaySenderMXBean.class, true);
System.out.println("SCache's GW sender queue size = " + gsmxbean.getEventQueueSize());