Getting Broker Client Statistics
The BrokerAdminClient.getClientStatsById method allows you to obtain statistics for a Broker client with a particular client identifier. The statistics are returned as fields within a BrokerEvent. You can retrieve each field using the BrokerEvent.get<type>Field method, described in the webMethods Broker Client Java API Programmer’s Guide. The version of the get<type>Field method to be used will depend on the data type of field you are retrieving.
The following example illustrates how to obtain the system usage statistics and extract the value of two fields. In this example, the client identifier is hard-coded. See
Obtaining Broker Client Identifiers for information on discovering client identifiers at run time.
. . .
int events_published;
int events_retrieved;
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 Broker client stats */
e = c.getClientStatsById("A123");
/* Get the number of events the Broker client has published */
events_published = e.getIntegerField( "numEventsPublished");
/* Get the number of events the Broker client has retrieved*/
events_retrieved = e.getIntegerField( "numEventsRetrieved");
. . .
} catch (BrokerException ex) {
System.out.println("Error while getting Broker statistics\n"+ex);
return;
}
. . .