protected void QueueObserverThread(object state)
        {
            // Only one instance of ServiceBus should listen to a particular queue
            var mutexName = $"Paralect.ServiceBus.{_transportEndpointAddress.GetFriendlyName()}";

            MutexFactory.LockByMutex(mutexName, () =>
            {
                var started = ObserverStarted;
                started?.Invoke(this);

                Log.Info("Paralect Service [{0}] bus started and listen to the {1} queue...", "_configuration.Name", _transportEndpointAddress.GetFriendlyName());
                Observe();
            });
        }
        protected void QueueObserverThread(object state)
        {
            // Only one instance of ServiceBus should listen to a particular queue
            String mutexName = String.Format("Paralect.ServiceBus.{0}", _configuration.InputQueue.GetFriendlyName());

            MutexFactory.LockByMutex(mutexName, () =>
            {
                CheckAvailabilityOfQueue(_configuration.InputQueue);
                CheckAvailabilityOfQueue(_configuration.ErrorQueue);

                var msmqQueueObserver = (MsmqQueueObserver)state;

                _logger.Info("Paralect Service [{0}] bus started and listen to the {1} queue...", _configuration.Name, _configuration.InputQueue.GetFriendlyName());
                _started = true;
                msmqQueueObserver.Listen();
                _started = false;
            });
        }
        /// <summary>
        /// Check existence of input and error endpoint and create them if needed
        /// </summary>
        private void PrepareQueues()
        {
            // Prepare input endpoint
            var inputMutexName =
                $"Paralect.ServiceBus.{_inputTransportEndpointAddress.GetFriendlyName()}.InputQueue";

            if (!_provider.ExistsEndpoint(_inputTransportEndpointAddress))
            {
                MutexFactory.LockByMutex(inputMutexName, () =>
                {
                    if (!_provider.ExistsEndpoint(_inputTransportEndpointAddress))
                    {
                        _provider.CreateEndpoint(_inputTransportEndpointAddress);
                    }
                });
            }

            _provider.PrepareEndpoint(_inputTransportEndpointAddress);


            // Prepare error endpoint
            var errorMutexName =
                $"Paralect.ServiceBus.{_inputTransportEndpointAddress.GetFriendlyName()}.ErrorQueue";

            if (!_provider.ExistsEndpoint(_errorTransportEndpointAddress))
            {
                MutexFactory.LockByMutex(errorMutexName, () =>
                {
                    if (!_provider.ExistsEndpoint(_errorTransportEndpointAddress))
                    {
                        _provider.CreateEndpoint(_errorTransportEndpointAddress);
                    }
                });
            }

            _provider.PrepareEndpoint(_errorTransportEndpointAddress);
        }