SecurityLayer securityLayer = SecurityLayerFactory.newInstance(settings);
OutgoingNetworkTransport transport = Transport.getOutgoingTransportInstance(getProtocolVersion());
NetworkConnection network = transport.connect(settings, securityLayer.receiver(_conn.getProtocolHandler()),
_conn.getProtocolHandler());
_conn.getProtocolHandler().setNetworkConnection(network, securityLayer.sender(network.getSender()));
StateWaiter waiter = _conn.getProtocolHandler().createWaiter(openOrClosedStates);
_conn.getProtocolHandler().getProtocolSession().init(settings);
// this blocks until the connection has been set up or when an error
// has prevented the connection being set up
AMQState state = waiter.await();
if(state == AMQState.CONNECTION_OPEN)
{
_conn.getFailoverPolicy().attainedConnection();
_conn.setConnected(true);
_conn.logConnected(network.getLocalAddress(), network.getRemoteAddress());
return null;
}
else
{
return _conn.getProtocolHandler().getSuggestedProtocolVersion();