Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Load Balancing and Failover for Publish Operations | Using BrokerClusterPublisher | Reconnecting a BrokerClusterPublisher
 
Reconnecting a BrokerClusterPublisher
You can reconnect to a previously disconnected BrokerClusterPublisher that has a life cycle of explicit-destroy on the application clients by calling BrokerClusterPublisher.reconnect methods specifying the same client ID that was used when the BrokerClusterPublisher was originally created as shown in the following example.
class ClusterPublish1
{
static String broker_host = "localhost";
static String broker_name = null;
static String client_group = "default";
. . .
public static void main(String args[])
{
BrokerClusterPublisher bcp;
. . .
/* Create */
try {
bcp = new BrokerClusterPublisher(broker_host, broker_name,
"ClusterPub", client_group, "Cluster Publish Sample
#1",null, null);
} catch (BrokerException ex) {
System.out.println("Error on create cluster
publisher\n"+ex);
return;
}
. . .
/* Disconnect */
try {
bcp.disconnect();
} catch (BrokerException ex) {
System.out.println("Error on disconnect\n"+ex);
return;
}
 
/* Reconnect */
try {
bcp = BrokerClusterPublisher.reconnect(broker_host,
broker_name, "ClusterPub", client_group, "Cluster
Publish Sample #1",null, null);
} catch (BrokerException ex) {
System.out.println("Error on reconnecting cluster
publisher\n"+ex);
return;
}
. . .