}
private boolean reconnectToBroker(BrokerCObj bCObj)
throws BrokerAdminException {
BrokerAdmin ba = bCObj.getBrokerAdmin();
boolean connected = false;
int count = 0;
while (!connected && (count < BrokerAdmin.RECONNECT_RETRIES)) {
try {
count++;
ba.connect();
ba.sendHelloMessage();
ba.receiveHelloReplyMessage();
connected = true;
/*
* Add a listener to unexpected error reporting only
* after a successful connect.
* Set the initiator to false. This flag should only
* be set to true when it is ready to preform a shutdown.
*/
ba.addAdminEventListener(this);
ba.setInitiator(false);
} catch (BrokerAdminException baex) {
// try to reconnect based on RECONNECT attributes
if (baex.getType() == BrokerAdminException.CONNECT_ERROR) {
try {
Thread.sleep(BrokerAdmin.RECONNECT_DELAY);
} catch (InterruptedException ie) {
JOptionPane.showOptionDialog(app.getFrame(),
acr.getString(acr.E_RECONNECT_BROKER, ba.getKey()) +
ie.toString(),
acr.getString(acr.I_BROKER) + ": " +
acr.getString(acr.I_ERROR_CODE,
AdminConsoleResources.E_RECONNECT_BROKER),
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE, null, close, close[0]);
// Update the node
app.getExplorer().nodeChanged((DefaultMutableTreeNode)bCObj);
// Update menu items, buttons.
controller.setActions(bCObj);
}
} else {
JOptionPane.showOptionDialog(app.getFrame(),
acr.getString(acr.E_RECONNECT_BROKER, ba.getKey()) +
baex.toString(),
acr.getString(acr.I_BROKER) + ": " +
acr.getString(acr.I_ERROR_CODE,
AdminConsoleResources.E_RECONNECT_BROKER),
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE, null, close, close[0]);
// Update the node
app.getExplorer().nodeChanged((DefaultMutableTreeNode)bCObj);
// Update menu items, buttons.
controller.setActions(bCObj);
}
} catch (Exception ex) {
JOptionPane.showOptionDialog(app.getFrame(),
acr.getString(acr.E_RECONNECT_BROKER, ba.getKey()) +
ex.toString(),
acr.getString(acr.I_BROKER) + ": " +
acr.getString(acr.I_ERROR_CODE,
AdminConsoleResources.E_RECONNECT_BROKER),
JOptionPane.YES_NO_OPTION,