Listing all Brokers on a Host
The BrokerServerClient.getBrokers method lets you obtain a list of all the Brokers running in the Broker Server to which your BrokerServerClient is connected. An array of BrokerInfo objects is returned and each element contains details such as a Broker's name, description, and territory information. This method is available to all Broker Server clients.
The following example illustrates how to list all Brokers in a Broker Server:
. . .
int i;
BrokerInfo brokers[];
BrokerServerClient c;
try {
/* Create a Broker Server client */
c = new BrokerServerClient(broker_host, null);
/* Get a list of all Brokers in this server and print them out*/
brokers = c.getBrokers();
for(i = 0; i < brokers.length; i++) {
System.out.println(brokers[i].broker_name+"\n");
}
} catch (BrokerException ex) {
System.out.println("Error getting Broker list\n"+ex);
return;
}
. . .