// Now we absolutely know that no threads are executing in or blocked in createSession, and no
// more will execute it until failover is complete
// So.. do failover / reconnection
CoreRemotingConnection oldConnection = connection;
connection = null;
try
{
connector.close();
}
catch (Exception ignore)
{
}
cancelScheduledTasks();
connector = null;
if (attemptFailover)
{
// Now try failing over to backup
connectorFactory = backupConnectorFactory;
transportParams = backupTransportParams;
backupConnectorFactory = null;
backupTransportParams = null;
reconnectSessions(oldConnection, reconnectAttempts == -1 ? -1 : reconnectAttempts + 1);
}
else
{
reconnectSessions(oldConnection, reconnectAttempts);
}
oldConnection.destroy();
}
else
{
connection.destroy();