Beispiel #1
0
        public SqsQueueDefinition CreateQueue(string queueName, SqsMqWorkerInfo info, string redriveArn = null)
        {
            var redrivePolicy = string.IsNullOrEmpty(redriveArn)
                ? null
                : new SqsRedrivePolicy
            {
                MaxReceiveCount     = Math.Max(info.RetryCount, 1), //Valid Range 1-1000
                DeadLetterTargetArn = redriveArn
            };

            return(CreateQueue(GetSqsQueueName(queueName), info.VisibilityTimeout, info.ReceiveWaitTime,
                               info.DisableBuffering, redrivePolicy));
        }
Beispiel #2
0
        public SqsMqWorker(ISqsMqMessageFactory mqFactory,
                           SqsMqWorkerInfo queueWorkerInfo,
                           string queueName,
                           Action <SqsMqWorker, Exception> errorHandler)
        {
            Guard.AgainstNullArgument(mqFactory, "mqFactory");
            Guard.AgainstNullArgument(queueWorkerInfo, "queueWorkerInfo");
            Guard.AgainstNullArgument(queueName, "queueName");
            Guard.AgainstNullArgument(queueWorkerInfo.MessageHandlerFactory, "queueWorkerInfo.MessageHandlerFactory");

            this.mqFactory       = mqFactory;
            this.queueWorkerInfo = queueWorkerInfo;
            this.errorHandler    = errorHandler;
            messageHandler       = this.queueWorkerInfo.MessageHandlerFactory.CreateMessageHandler();
            QueueName            = queueName;
        }
        public SqsQueueDefinition CreateQueue(string queueName, SqsMqWorkerInfo info, string redriveArn = null)
        {
            var redrivePolicy = string.IsNullOrEmpty(redriveArn)
                ? null
                : new SqsRedrivePolicy
                {
                    MaxReceiveCount = Math.Max(info.RetryCount, 1), //Valid Range 1-1000
                    DeadLetterTargetArn = redriveArn
                };

            return CreateQueue(GetSqsQueueName(queueName), info.VisibilityTimeout, info.ReceiveWaitTime,
                               info.DisableBuffering, redrivePolicy);
        }
        public void Create_updates_existing_queue_when_created_with_different_attributes()
        {
            var info = new SqsMqWorkerInfo
            {
                VisibilityTimeout = 11,
                ReceiveWaitTime = 9,
                DisableBuffering = true,
                RetryCount = 6
            };

            var redriveQd = sqsQueueManager.CreateQueue(GetNewId(), info);

            var qd = sqsQueueManager.CreateQueue(GetNewId(), info, redriveArn: redriveQd.QueueArn);

            Assert.IsNotNull(qd, "First Queue Definition");
            Assert.IsTrue(sqsQueueManager.QueueExists(qd.QueueName), "First Queue");

            var newRedriveQd = sqsQueueManager.CreateQueue(GetNewId(), info);
            
            var newQd = sqsQueueManager.CreateQueue(qd.QueueName, 
                visibilityTimeoutSeconds: 12,
                receiveWaitTimeSeconds: 10, disasbleBuffering: false,
                redrivePolicy: new SqsRedrivePolicy {
                    DeadLetterTargetArn = newRedriveQd.QueueArn,
                    MaxReceiveCount = 7
                });

            Assert.IsNotNull(newQd, "New Queue Definition");
            Assert.AreEqual(newQd.VisibilityTimeout, 12, "VisibilityTimeout");
            Assert.AreEqual(newQd.ReceiveWaitTime, 10, "ReceiveWaitTime");
            Assert.AreEqual(newQd.DisableBuffering, false, "DisableBuffering");
            Assert.IsNotNull(newQd.RedrivePolicy, "RedrivePolicy");
            Assert.AreEqual(newQd.RedrivePolicy.MaxReceiveCount, 7, "RetryCount");
            Assert.AreEqual(newQd.RedrivePolicy.DeadLetterTargetArn, newRedriveQd.QueueArn, "Redrive TargetArn");

        }
        public void Create_includes_correct_info_when_created_from_worker()
        {
            var info = new SqsMqWorkerInfo
            {
                VisibilityTimeout = 11,
                ReceiveWaitTime = 9,
                DisableBuffering = true,
                RetryCount = 6
            };

            var redriveQd = sqsQueueManager.CreateQueue(GetNewId(), info);

            var qd = sqsQueueManager.CreateQueue(GetNewId(), info, redriveArn: redriveQd.QueueArn);

            Assert.IsNotNull(qd, "Queue Definition");
            Assert.AreEqual(qd.VisibilityTimeout, info.VisibilityTimeout, "VisibilityTimeout");
            Assert.AreEqual(qd.ReceiveWaitTime, info.ReceiveWaitTime, "ReceiveWaitTime");
            Assert.AreEqual(qd.DisableBuffering, info.DisableBuffering, "DisableBuffering");

            Assert.IsNotNull(qd.RedrivePolicy, "RedrivePolicy");
            Assert.AreEqual(qd.RedrivePolicy.MaxReceiveCount, info.RetryCount, "RetryCount");
            Assert.AreEqual(qd.RedrivePolicy.DeadLetterTargetArn, redriveQd.QueueArn, "Redrive TargetArn");

        }