String name = UUIDGenerator.getInstance().generateSimpleStringUUID().toString();
boolean retry = false;
do
{
Version clientVersion = VersionLoader.getVersion();
CoreRemotingConnection theConnection = null;
Lock lock = null;
try
{
Channel channel1;
synchronized (failoverLock)
{
theConnection = getConnectionWithRetry(reconnectAttempts);
if (theConnection == null)
{
if (exitLoop)
{
return null;
}
if (failoverOnInitialConnection && backupConnectorFactory != null)
{
// Try and connect to the backup
log.warn("Server is not available to make initial connection to. Will " + "try backup server instead.");
connectorFactory = backupConnectorFactory;
transportParams = backupTransportParams;
backupConnectorFactory = null;
backupTransportParams = null;
theConnection = getConnectionWithRetry(reconnectAttempts);
}
if (exitLoop)
{
return null;
}
if (theConnection == null)
{
throw new HornetQException(HornetQException.NOT_CONNECTED,
"Unable to connect to server using configuration " + connectorConfig);
}
}
channel1 = theConnection.getChannel(1, -1);
// Lock it - this must be done while the failoverLock is held
channel1.getLock().lock();
lock = channel1.getLock();
} // We can now release the failoverLock
// We now set a flag saying createSession is executing
synchronized (exitLock)
{
inCreateSession = true;
}
long sessionChannelID = theConnection.generateChannelID();
Packet request = new CreateSessionMessage(name,
sessionChannelID,
clientVersion.getIncrementingVersion(),
username,
password,
minLargeMessageSize,
xa,
autoCommitSends,