Exemplo n.º 1
0
        public async Task Then_The_Message_Retention_Period_Is_Updated()
        {
            // Arrange
            ILoggerFactory    loggerFactory = OutputHelper.ToLoggerFactory();
            IAwsClientFactory clientFactory = CreateClientFactory();

            var client = clientFactory.GetSqsClient(Region);

            var queue = new ErrorQueue(
                Region,
                UniqueName,
                client,
                loggerFactory);

            var queueConfig = new SqsBasicConfiguration()
            {
                ErrorQueueRetentionPeriod = JustSayingConstants.MaximumRetentionPeriod,
                ErrorQueueOptOut          = true,
            };

            // Act
            await queue.CreateAsync(queueConfig);

            queueConfig.ErrorQueueRetentionPeriod = TimeSpan.FromSeconds(100);

            await queue.UpdateQueueAttributeAsync(queueConfig, CancellationToken.None);

            // Assert
            queue.MessageRetentionPeriod.ShouldBe(TimeSpan.FromSeconds(100));
        }
Exemplo n.º 2
0
        public async Task EnsureQueueAndErrorQueueExistAndAllAttributesAreUpdatedAsync(SqsReadConfiguration queueConfig)
        {
            if (queueConfig == null)
            {
                throw new ArgumentNullException(nameof(queueConfig));
            }

            var exists = await ExistsAsync().ConfigureAwait(false);

            if (!exists)
            {
                await CreateAsync(queueConfig).ConfigureAwait(false);
            }
            else
            {
                await UpdateQueueAttributeAsync(queueConfig).ConfigureAwait(false);
            }

            await ApplyTagsAsync(this, queueConfig.Tags).ConfigureAwait(false);

            //Create an error queue for existing queues if they don't already have one
            if (ErrorQueue != null && NeedErrorQueue(queueConfig))
            {
                var errorQueueConfig = new SqsReadConfiguration(SubscriptionType.ToTopic)
                {
                    ErrorQueueRetentionPeriod = queueConfig.ErrorQueueRetentionPeriod,
                    ErrorQueueOptOut          = true
                };

                var errorQueueExists = await ErrorQueue.ExistsAsync().ConfigureAwait(false);

                if (!errorQueueExists)
                {
                    await ErrorQueue.CreateAsync(errorQueueConfig).ConfigureAwait(false);
                }
                else
                {
                    await ErrorQueue.UpdateQueueAttributeAsync(errorQueueConfig).ConfigureAwait(false);
                }

                await UpdateRedrivePolicyAsync(
                    new RedrivePolicy(queueConfig.RetryCountBeforeSendingToErrorQueue, ErrorQueue.Arn)).ConfigureAwait(false);

                await ApplyTagsAsync(ErrorQueue, queueConfig.Tags).ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        public async Task EnsureQueueAndErrorQueueExistAndAllAttributesAreUpdatedAsync(SqsBasicConfiguration queueConfig)
        {
            var exists = await ExistsAsync();

            if (!exists)
            {
                await CreateAsync(queueConfig);
            }
            else
            {
                await UpdateQueueAttributeAsync(queueConfig);
            }

            //Create an error queue for existing queues if they don't already have one
            if (ErrorQueue != null && NeedErrorQueue(queueConfig))
            {
                var errorQueueConfig = new SqsReadConfiguration(SubscriptionType.ToTopic)
                {
                    ErrorQueueRetentionPeriodSeconds = queueConfig.ErrorQueueRetentionPeriodSeconds,
                    ErrorQueueOptOut = true
                };

                var errorQueueExists = await ErrorQueue.ExistsAsync();

                if (!errorQueueExists)
                {
                    await ErrorQueue.CreateAsync(errorQueueConfig);
                }
                else
                {
                    await ErrorQueue.UpdateQueueAttributeAsync(errorQueueConfig);
                }

                await UpdateRedrivePolicyAsync(
                    new RedrivePolicy(queueConfig.RetryCountBeforeSendingToErrorQueue, ErrorQueue.Arn));
            }
        }