Apache.NMS.ActiveMQ.Transport.Discovery.Multicast.MulticastDiscoveryAgent.Start C# (CSharp) Method

Start() public method

public Start ( ) : void
return void
        public void Start()
        {
            lock(stopstartSemaphore)
            {
                if (discoveryUri == null)
                {
                    discoveryUri = new Uri(DEFAULT_DISCOVERY_URI_STRING);
                }

                if(multicastSocket == null)
                {
                    int numFailedAttempts = 0;
                    int backoffTime = DEFAULT_BACKOFF_MILLISECONDS;

                    Tracer.Info("Connecting to multicast discovery socket.");
                    while(!TryToConnectSocket())
                    {
                        numFailedAttempts++;
                        if(numFailedAttempts > MAX_SOCKET_CONNECTION_RETRY_ATTEMPS)
                        {
                            throw new ApplicationException(
                                "Could not open the socket in order to discover advertising brokers.");
                        }

                        Thread.Sleep(backoffTime);
                        backoffTime *= BACKOFF_MULTIPLIER;
                    }
                }

                if(worker == null)
                {
                    Tracer.Info("Starting multicast discovery agent worker thread");
                    worker = new Thread(new ThreadStart(worker_DoWork));
                    worker.IsBackground = true;
                    worker.Start();
                    isStarted = true;
                }
            }
        }