Apache.NMS.ActiveMQ.Transport.Discovery.DiscoveryTransportFactory.CreateTransport C# (CSharp) Method

CreateTransport() public method

public CreateTransport ( Uri location ) : ITransport
location System.Uri
return ITransport
        public ITransport CreateTransport(Uri location)
        {
            URISupport.CompositeData cd = URISupport.ParseComposite(location);

            if(cd.Components.Length > 0)
            {
                agent.DiscoveryURI = cd.Components[0];
            }

            if(!agent.IsStarted)
            {
                agent.Start();
            }

            Uri hostUri = DiscoveredUri;

            if(null == hostUri)
            {
                // If a new broker is found the agent will fire an event which will result in discoveredUri being set.
                discoveredUriEvent.WaitOne(TIMEOUT_IN_SECONDS * 1000, true);
                hostUri = DiscoveredUri;
                if(null == hostUri)
                {
                    throw new NMSConnectionException(String.Format("Unable to find a connection to {0} before the timeout period expired.", location.ToString()));
                }
            }

            TcpTransportFactory tcpTransFactory = new TcpTransportFactory();
            return tcpTransFactory.CompositeConnect(new Uri(hostUri + location.Query));
        }