Disconnecting Broker Clients
You can use the BrokerAdminClient.disconnectClientById method to disconnect all Broker clients using a specific client identifier. If the Broker client's life cycle is destroy-on-disconnect, the client state and event queue storage will be destroyed by the Broker. If the Broker client's life cycle is explicit-destroy, the client state and event queue storage will be preserved by the Broker until the Broker client reconnects.
Note:
If more than one client application is sharing the same client state, they are using the same client ID and they will all be disconnected.
The following example illustrates how to disconnect a
BrokerClient by client identifier. In this example, the client identifier is hard-coded. See
Obtaining Broker Client Identifiers for information on discovering client identifiers at run time.
. . .
BrokerAdminClient c;
try {
/* Create a Broker admin client */
c = new BrokerAdminClient(broker_host, broker_name, null,
client_group, "My Broker Monitor",null);
/* Disconnect all Broker clients with a specific client identifier */
c.disconnectClientById("A123");
} catch (BrokerException ex) {
System.out.println("Error while disconnecting BrokerClient\n"+ex);
return;
}
. . .