Reconnecting a BrokerAdminClient
You can reconnect a previously disconnected Broker client that has a life cycle of explicit-destroy by invoking the reconnectAdmin method and specifying the same client ID that was used when your client was last connected, as shown in the example below.
If the Broker client's life cycle is explicit-destroy, the client state and event queue storage will have been preserved by the Broker since previous invocation of the disconnect method.
The following example illustrates how to reconnect a BrokerAdminClient:
static String broker_host = "localhost";
static String broker_name = null;
static String client_group = "myExplicitDestroyClientGroup";
. . .
public static void main(String args[])
{
BrokerAdminClient c;
String client_id;
. . .
/* Create an admin client */
try {
c = new BrokerAdminClient(broker_host, broker_name, null,
client_group, "My Broker Monitor",null);
} catch (BrokerException ex) {
. . .
}
/* Save the client ID */
client_id = c.getClientId();
. . .
/* Disconnect the admin client */
try {
c.disconnect();
} catch (BrokerException ex) {
. . .
}
. . .
/* Reconnect the admin client with the same client_id */
try {
c.reconnectAdmin(broker_host, broker_name, client_id, null);
} catch (BrokerException ex) {
. . .
}
. . .