Ejemplo n.º 1
0
        /// <summary>
        /// Check existence of input and error endpoint and create them if needed
        /// </summary>
        private void PrepareQueues()
        {
            // Prepare input endpoint
            String inputMutexName = String.Format("Paralect.ServiceBus.{0}.InputQueue", _inputTransportEndpointAddress.GetFriendlyName());

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

            _provider.PrepareEndpoint(_inputTransportEndpointAddress);


            // Prepare error endpoint
            String errorMutexName = String.Format("Paralect.ServiceBus.{0}.ErrorQueue", _inputTransportEndpointAddress.GetFriendlyName());

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

            _provider.PrepareEndpoint(_errorTransportEndpointAddress);
        }
Ejemplo n.º 2
0
        protected void QueueObserverThread(object state)
        {
            // Only one instance of ServiceBus should listen to a particular queue
            String mutexName = String.Format("Paralect.ServiceBus.{0}", _transportEndpointAddress.GetFriendlyName());

            MutexFactory.LockByMutex(mutexName, () =>
            {
                var started = ObserverStarted;
                if (started != null)
                {
                    started(this);
                }

                _log.Info("Paralect Service [{0}] bus started and listen to the {1} queue...", "_configuration.Name", _transportEndpointAddress.GetFriendlyName());
                Observe();
            });
        }