Пример #1
0
        public static uint CreateIfNotExist(MessageQueueRequest request)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            _validator.SetObject(request.QueuePath);
            if (!_validator.Validate())
                throw new InvalidOperationException(string.Format("Queue name is invalid, {0}", request.QueuePath));

            try
            {
                if (!System.Messaging.MessageQueue.Exists(request.QueuePath))
                {
                    System.Messaging.MessageQueue.Create(request.QueuePath, request.IsTransactional);
                    return 1;
                }
                return 0;
            }
            catch (Exception ex)
            {
                if (DefaultSingleton<ILog>.Instance != null)
                    DefaultSingleton<ILog>.Instance.Error(string.Format("Error creating or accessing MSMQ {0}", request.QueuePath), ex);
                return 2;
            }
        }
Пример #2
0
        public void CreateIfNotExistsTest()
        {
            var req = new EventBus.MessageQueue.Infrastructure.MessageQueueRequest() { QueuePath = ".\\Private$\\EventBusMQ" };
            var result = EventBus.MessageQueue.Extensions.Utilities.CreateIfNotExist(req);
            Assert.IsTrue(result == 1);

            result = EventBus.MessageQueue.Extensions.Utilities.DeleteQueue(req.QueuePath);
            Assert.IsTrue(result == 1);
        }
Пример #3
0
        public void CreateIfNotExistsTest()
        {
            var req = new EventBus.MessageQueue.Infrastructure.MessageQueueRequest()
            {
                QueuePath = ".\\Private$\\EventBusMQ"
            };
            var result = EventBus.MessageQueue.Extensions.Utilities.CreateIfNotExist(req);

            Assert.IsTrue(result == 1);

            result = EventBus.MessageQueue.Extensions.Utilities.DeleteQueue(req.QueuePath);
            Assert.IsTrue(result == 1);
        }