Object MBeanPage edited by Robbie GemmellChanges (1)
Full Content
Object MBeanDescriptionQMan JMX representation of a Qpid domain object exposed for management / monitoring. Note that there will be an object MBean for each management object on Qpid. Object NameQ-MAN:brokerId=<BROKER_ID>,type=Object,package=<PACKAGE_NAME>,class=<CLASS_NAME>,objectId=<OBJECT_ID> where :
AttributesObject MBean attributes can be classifiled under two categories :
The JMX interface of an object MBean lets you retrieve attributes metadata using the standard JMX API. The following example is showing that. Example : retrieving attributes metadata public class Example { public static void main(String[] args) throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); // Suppose the following is an object name associated with an existing managed domain instance. ObjectName objectName = ...; MBeanInfo mbeanMetadata = server.getMBeanInfo(objectName); // List all attributes (metadata, not values) for (MBeanAttributeInfo attribute : mbeanMetadata.getAttributes()) { System.out.println("Name : "+attribute.getName()); System.out.println("Description : "+attribute.getDescription()); System.out.println("Type : "+attribute.getType()); System.out.println("Is Readable : "+attribute.isReadable()); System.out.println("Is Writable : "+attribute.isWritable()); } } } Operations
getAttribute
Example public class Example { public static void main(String[] args) throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); // Suppose that this is an object name corresponding to a valid managed domain instance. ObjectName objectName = ...; // Suppose the mbean has an attribute (a statistic in this case) PendingMessagesCount Long attributeValue = (Long) server.getAttribute(objectName, "PendingMessagesCount"); System.out.println("Attribute Value : "+attributeValue); } } setAttribute
Example public class Example { public static void main(String[] args) throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); // Suppose that this is an object name corresponding to a valid managed domain instance. ObjectName objectName = ...; // Suppose we want to set a value of 30000 for "MgmtPubInterval" attribute. Attribute attribute = new Attribute("MgmtPubInterval",new Long(3000)); server.setAttribute(objectName, attribute); } } invoke
While mostly the interface follows the same rules of javax.management.MBeanServer.invoke() the only difference resides on return type.
Example public class Example { public static void main(String[] args) throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); // Suppose that this is an object name corresponding to a valid managed domain instance. ObjectName objectName = new ObjectName("A:N=1"); // Suppose the mbean has an operation // public int purge(int request) try { String outputParameterName = "result"; String operationName = "purge"; Object [] parameters = new Object[]{1235}; String [] signature = new String[]{int.class.getName()}; InvocationResult result = (InvocationResultserver.invoke( objectName, operationName, parameters, signature); // Output parameters map Map<String,Object> outputSection = result.getOutputSection(); // Output parameter Integer outputParameter = (Integer) outputSection.get(outputParameterName); System.out.println("Output parameter : "+outputParameter); } catch (MBeanException exception) { Exception nested = exception.getTargetException(); if (nested instanceof MethodInvocationException) { MethodInvocationException invocationException = (MethodInvocationException) nested; System.out.println("Status Code : "+invocationException.getReturnCode()); System.out.println("Status Text : "+invocationException.getStatusText()); } } } } NotificationsN.A.
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
