Version version = getVersionToUse(serverVersion);
byte v = version.getProviderIncrementingVersion();
JMSRemotingConnection remotingConnection = null;
CreateConnectionResult res;
try
{
remotingConnection = new JMSRemotingConnection(serverLocatorURI, clientPing, strictTck, new ConsolidatedRemotingConnectionListener(), sendAcksAsync);
remotingConnection.start();
Client client = remotingConnection.getRemotingClient();
String remotingSessionId = client.getSessionId();
String clientVMId = JMSClientVMIdentifier.instance;
ConnectionFactoryCreateConnectionDelegateRequest req =
new ConnectionFactoryCreateConnectionDelegateRequest(id, v,
remotingSessionId, clientVMId,
username, password, failedNodeID);
ResponseSupport rs = (ResponseSupport)client.invoke(req, null);
res = (CreateConnectionResult)rs.getResponse();
}
catch (Throwable t)
{
//If we were invoking createConnectionDelegate and failure occurs then we need to clear
// up the JMSRemotingConnection
if (remotingConnection != null)
{
try
{
remotingConnection.stop();
}
catch (Throwable ignore)
{
}
}
throw handleThrowable(t);
}
ClientConnectionDelegate connectionDelegate = (ClientConnectionDelegate)res.getDelegate();
if (connectionDelegate != null)
{
connectionDelegate.setRemotingConnection(remotingConnection);
connectionDelegate.setVersionToUse(version);
connectionDelegate.setEnableOrderingGroup(this.enableOrderingGroup);
connectionDelegate.setDefaultOrderingGroup(this.defaultOrderingGroupName);
}
else
{
//Wrong server redirect on failure
//close the remoting connection
try
{
remotingConnection.stop();
}
catch (Throwable ignore)
{
}
}