Broker 10.5 | webMethods Broker Documentation | webMethods Broker Administration Java API Programmer’s Guide | Managing Broker Clients | Broker Administration | Getting Broker Statistics
 
Getting Broker Statistics
The BrokerAdminClient.getBrokerStats method allows you to obtain statistics for a Broker. The statistics are returned as fields within a BrokerEvent.
After you have obtained the BrokerEvent containing the statistics, you can retrieve each field using the BrokerEvent.get<type>Field method. The version of the get<type>Field method to be used will depend on the data type of the field you are retrieving. The following example illustrates how to obtain a BrokerEvent containing the system usage statistics and extract the value of two fields.
. . .
int num_clients;
int num_event_types;
BrokerDate create_date;
BrokerEvent e;
BrokerAdminClient c;
try {
/* Create a Broker admin client */
c = new BrokerAdminClient(broker_host, broker_name, null,
client_group, "My Broker Monitor",null);
 
/* Get the BrokerEvent containing the Broker’s statistics */
e = c.getBrokerStats();
/* Get the time and date that the Broker was created */
create_date = e.getDateField( "createTime");
/* Get the number of connected clients */
num_clients = e.getIntegerField( "numClients");
/* Get the number of event type definitions */
num_event_types = e.getIntegerField( "numEventTypes");
. . .
} catch (BrokerException ex) {
System.out.println("Error getting Broker statistics\n"+ex);
return;
}
. . .