Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Load Balancing and Failover for Publish Operations | Broker Cluster Publisher Connection Notification | Canceling the Connection Callback Object
 
Canceling the Connection Callback Object
You can un-register a callback by invoking the BrokerClusterPublisher.cancelConnectionCallback.
static class ClusterConnCallback implements BrokerCPConnectionCallback
{
public void handleConnectionChange(BrokerClusterPublisher bcp,
int state,
String conn_str,
Object client_data) {
System.out.print("Connection change on : "+conn_str+ " - ");
if (state == BrokerClient.CONNECT_STATE_CONNECTED)
System.out.println(" CONNECTED");
else if (state == BrokerClient.CONNECT_STATE_DISCONNECTED)
System.out.println(" DISCONNECTED");
}
}
public static void main(String args[])
{
BrokerClusterPublisher bcp;
ClusterConnCallback conn_cb;
BrokerEvent e;
. . .
/* create BrokerClusterPublisher */
. . .
/* create and register connection callback */
conn_cb = new ClusterConnCallback();
try {
bcp.registerConnectionCallback( conn_cb, null)
} catch (BrokerException ex) {
System.out.println("Error in registering connection callback");
return;
}
. . .
/* operations on BrokerClusterPublisher */
try {
bcp.cancelConnectionCallback()
} catch (BrokerException ex) {
System.out.println("Error in canceling connection callback");
return;
}
/* disconnect or destroy up BrokerClusterPublisher */
. . .
 
}