コード例 #1
0
        MessageQueue GetInputQueue()
        {
            if (_inputQueue != null)
            {
                return(_inputQueue);
            }

            lock (this)
            {
                if (_inputQueue != null)
                {
                    return(_inputQueue);
                }

                var inputQueuePath = MsmqUtil.GetPath(_inputQueueName);

                if (_newQueueCallbacks.Any())
                {
                    MsmqUtil.EnsureQueueExists(inputQueuePath, _log, messageQueue =>
                    {
                        _newQueueCallbacks.ForEach(callback => callback(messageQueue));
                    });
                }
                else
                {
                    MsmqUtil.EnsureQueueExists(inputQueuePath, _log);
                }
                MsmqUtil.EnsureMessageQueueIsTransactional(inputQueuePath);

                _inputQueue = new MessageQueue(inputQueuePath, QueueAccessMode.SendAndReceive)
                {
                    MessageReadPropertyFilter = new MessagePropertyFilter
                    {
                        Id        = true,
                        Extension = true,
                        Body      = true,
                    }
                };
            }

            return(_inputQueue);
        }
コード例 #2
0
        /// <summary>
        /// Creates a queue with the given address, unless the address is of a remote queue - in that case,
        /// this call is ignored
        /// </summary>
        public void CreateQueue(string address)
        {
            if (!MsmqUtil.IsLocal(address))
            {
                return;
            }

            var inputQueuePath = MsmqUtil.GetPath(address);

            if (_newQueueCallbacks.Any())
            {
                MsmqUtil.EnsureQueueExists(inputQueuePath, _log, messageQueue =>
                {
                    _newQueueCallbacks.ForEach(callback => callback(messageQueue));
                });
            }
            else
            {
                MsmqUtil.EnsureQueueExists(inputQueuePath, _log);
            }

            MsmqUtil.EnsureMessageQueueIsTransactional(inputQueuePath);
        }