Broker 10.5 | webMethods Broker Documentation | webMethods Broker Administration Java API Programmer’s Guide | Managing Brokers and Broker Servers | Managing a Broker Server Configuration | Getting and Setting the Default Broker
 
Getting and Setting the Default Broker
You can use the BrokerServerClient.getDefaultBrokerName method to obtain the name of the default Broker on the Broker Server to which your BrokerServerClient is connected. If you do not specify a Broker name when you create a BrokerClient, your client will be connected to the default Broker.
You can use the BrokerServerClient.setDefaultBrokerName method to set the name of the default Broker.
The following example illustrates how to use the getDefaultBrokerName and setDefaultBrokerName methods to get and set the default Broker name.
. . .
String broker_name;
BrokerServerClient c;
. . .
/* Create a Broker Server client */
c = new BrokerServerClient(broker_host, null);
. . .
try {
/* Get the default Broker name */
broker_name = c.getDefaultBrokerName();
} catch (BrokerException ex) {
System.out.println("Error getting default Broker\n"+ex);
return;
}
try {
/* Set the default Broker name */
c.setDefaultBrokerName("My Broker");
. . .
} catch (BrokerException ex) {
System.out.println("Error setting default Broker\n"+ex);
return;
}
. . .