I have the following ObjectName which contains a CompositeData and some attributes:
Object o = jmxConnector.getMBeanServerConnection().
getAttribute(new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage");
CompositeData cd = (CompositeData) o;
System.out.println(cd.get("committed"));
That works well to return the amount of committed memory. Next, I'd like to add an attribute listener on the "committed" attribute. I've tried as follows:
connection = jmxConnector.getMBeanServerConnection();
ObjectName obj = new ObjectName("java.lang:type=Memory,name=HeapMemoryUsage.committed");
connection.addNotificationListener(obj, new JMXNotificationListener(), null, null);
However, that doesn't seem the right way to reference the HeapMemoryUsage:
javax.management.InstanceNotFoundException: java.lang:type=Memory,name=HeapMemoryUsage.committed
What is the correct way to reference to the committed attribute of HeapMemoryUsage? Thanks