Esempio n. 1
0
        public async Task CreateQueuesForEndpointDefaultMaxTTL(string delayedDeliveryMethod)
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"mycreatedefaultendpoint-{randomName}";
            var errorQueueName = $"mycreatedefaulterror-{randomName}";
            var auditQueueName = $"mycreatedefaultaudit-{randomName}";

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, delayedDeliveryMethod : delayedDeliveryMethod)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName)
                .ConfigureAwait(false);

                await AssertQueuesExist(endpointName, errorQueueName, auditQueueName, TimeSpan.FromDays(4), delayedDeliveryMethod : delayedDeliveryMethod)
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, delayedDeliveryMethod : delayedDeliveryMethod)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName)
                .ConfigureAwait(false);
            }
        }
Esempio n. 2
0
        public async Task CreateQueuesForEndpointWithRetries()
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"mycreateprefixendpoint-{randomName}";
            var errorQueueName = $"mycreateprefixerror-{randomName}";
            var auditQueueName = $"mycreateprefixaudit-{randomName}";

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, includeRetries : true)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName)
                .ConfigureAwait(false);

                await AssertQueuesExist(endpointName, errorQueueName, auditQueueName, TimeSpan.FromDays(4), includeRetries : true)
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, includeRetries : true)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName)
                .ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        public async Task CreateQueues()
        {
            var state = new State();
            IEndpointInstance endpoint = null;

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, includeRetries : true)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName)
                .ConfigureAwait(false);

                endpoint = await StartEndpoint(state).ConfigureAwait(false);

                var messageToSend = new MessageToSend();
                await endpoint.SendLocal(messageToSend).ConfigureAwait(false);

                Assert.IsTrue(await state.Signal.Task.ConfigureAwait(false));
            }
            finally
            {
                if (endpoint != null)
                {
                    await endpoint.Stop().ConfigureAwait(false);
                }
            }
        }
Esempio n. 4
0
        public async Task CreateQueuesForEndpointWithOverridenMaxTTL()
        {
            var maxTimeToLive  = TimeSpan.FromDays(1);
            var endpointName   = "mycreateendpoint";
            var errorQueueName = "mycreateerror";
            var auditQueueName = "mycreateaudit";

            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName)
            .ConfigureAwait(false);

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(
                    endpointName : endpointName,
                    maxTimeToLive : maxTimeToLive)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName,
                    maxTimeToLive : maxTimeToLive)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName,
                    maxTimeToLive : maxTimeToLive)
                .ConfigureAwait(false);

                await AssertQueuesExist(endpointName, errorQueueName, auditQueueName, maxTimeToLive)
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName)
                .ConfigureAwait(false);
            }
        }
Esempio n. 5
0
        public async Task CreateQueues(string delayedDeliveryMethod)
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"createqueues-{randomName}";
            var errorQueueName = $"createqueues-{randomName}-error";
            var auditQueueName = $"createqueues-{randomName}-audit";

            var state = new State();
            IEndpointInstance endpoint = null;

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, includeRetries : true, delayedDeliveryMethod : delayedDeliveryMethod)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName)
                .ConfigureAwait(false);

                endpoint = await StartEndpoint(state, endpointName, errorQueueName, auditQueueName, delayedDeliveryMethod).ConfigureAwait(false);

                var messageToSend = new MessageToSend();
                await endpoint.SendLocal(messageToSend).ConfigureAwait(false);

                Assert.IsTrue(await state.Signal.Task.ConfigureAwait(false));
            }
            finally
            {
                if (endpoint != null)
                {
                    await endpoint.Stop().ConfigureAwait(false);
                }

                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, includeRetries : true, delayedDeliveryMethod : delayedDeliveryMethod)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName)
                .ConfigureAwait(false);
            }
        }
Esempio n. 6
0
        public async Task CreateQueuesForEndpointWithPrefix()
        {
            var endpointName   = "mycreateprefixendpoint";
            var errorQueueName = "mycreateprefixerror";
            var auditQueueName = "mycreateprefixaudit";

            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, queueNamePrefix : "DEV")
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName,
                    queueNamePrefix : "DEV")
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName,
                    queueNamePrefix : "DEV")
                .ConfigureAwait(false);

                await AssertQueuesExist(endpointName, errorQueueName, auditQueueName, TimeSpan.FromDays(4), queueNamePrefix : "DEV")
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, queueNamePrefix : "DEV")
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName, queueNamePrefix : "DEV")
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName, queueNamePrefix : "DEV")
                .ConfigureAwait(false);
            }
        }
Esempio n. 7
0
        public async Task CreateQueuesForEndpointWithRetries()
        {
            var endpointName   = "mycreateretriesendpoint";
            var errorQueueName = "mycreateretrieserror";
            var auditQueueName = "mycreateretriesaudit";

            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, includeRetries : true)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName)
            .ConfigureAwait(false);

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, includeRetries : true)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName)
                .ConfigureAwait(false);

                await AssertQueuesExist(endpointName, errorQueueName, auditQueueName, TimeSpan.FromDays(4), includeRetries : true)
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, includeRetries : true)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName)
                .ConfigureAwait(false);
            }
        }
Esempio n. 8
0
        public async Task CreateQueuesForEndpointDefaultMaxTTL()
        {
            var endpointName   = "mycreatedefaultendpoint";
            var errorQueueName = "mycreatedefaulterror";
            var auditQueueName = "mycreatedefaultaudit";

            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName)
            .ConfigureAwait(false);

            try
            {
                await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : errorQueueName)
                .ConfigureAwait(false);

                await QueueCreationUtils.CreateQueue(
                    queueName : auditQueueName)
                .ConfigureAwait(false);

                await AssertQueuesExist(endpointName, errorQueueName, auditQueueName, TimeSpan.FromDays(4))
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName)
                .ConfigureAwait(false);
            }
        }
Esempio n. 9
0
        public static async Task CreateQueuesForEndpoint(string endpointName, TimeSpan?maxTimeToLive = null, string queueNamePrefix = null, bool includeRetries = false, string delayedDeliveryMethod = "Native")
        {
            switch (delayedDeliveryMethod)
            {
            case "TimeoutManager":

                // timeout dispatcher queue
                // This queue is created first because it has the longest name.
                // If the endpointName and queueNamePrefix are too long this call will throw and no queues will be created.
                // In this event, a shorter value for endpointName or queueNamePrefix should be used.
                await QueueCreationUtils.CreateQueue($"{endpointName}.TimeoutsDispatcher", maxTimeToLive, queueNamePrefix)
                .ConfigureAwait(false);

                // timeout queue
                await QueueCreationUtils.CreateQueue($"{endpointName}.Timeouts", maxTimeToLive, queueNamePrefix)
                .ConfigureAwait(false);

                break;

            case "UnrestrictedDelayedDelivery":

                await QueueCreationUtils.CreateQueue($"{endpointName}-delay.fifo", maxTimeToLive, queueNamePrefix)
                .ConfigureAwait(false);

                break;
            }

            // main queue
            await QueueCreationUtils.CreateQueue(endpointName, maxTimeToLive, queueNamePrefix)
            .ConfigureAwait(false);


            // retries queue
            if (includeRetries)
            {
                await QueueCreationUtils.CreateQueue($"{endpointName}.Retries", maxTimeToLive, queueNamePrefix)
                .ConfigureAwait(false);
            }
        }
Esempio n. 10
0
        async Task Usage()
        {
            #region sqs-create-queues-shared-usage

            await QueueCreationUtils.CreateQueue(
                queueName : "error",
                maxTimeToLive : TimeSpan.FromDays(2),
                queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(
                queueName : "audit",
                maxTimeToLive : TimeSpan.FromDays(2),
                queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            #endregion

            #region sqs-create-queues-shared-usage-cloudformation

            await QueueCreationUtilsCloudFormation.CreateQueue(
                queueName : "error",
                templatePath : @".\QueueCreation.json",
                maxTimeToLive : TimeSpan.FromDays(2),
                queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            await QueueCreationUtilsCloudFormation.CreateQueue(
                queueName : "audit",
                templatePath : @".\QueueCreation.json",
                maxTimeToLive : TimeSpan.FromDays(2),
                queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            #endregion
        }
Esempio n. 11
0
        public static async Task CreateQueuesForEndpoint(string endpointName, TimeSpan?maxTimeToLive = null, string queueNamePrefix = null, bool includeRetries = false)
        {
            // timeout dispatcher queue
            // This queue is created first because it has the longest name.
            // If the endpointName and queueNamePrefix are too long this call will throw and no queues will be created.
            // In this event, a shorter value for endpointName or queueNamePrefix should be used.
            await QueueCreationUtils.CreateQueue($"{endpointName}.TimeoutsDispatcher", maxTimeToLive, queueNamePrefix)
            .ConfigureAwait(false);

            // main queue
            await QueueCreationUtils.CreateQueue(endpointName, maxTimeToLive, queueNamePrefix)
            .ConfigureAwait(false);

            // timeout queue
            await QueueCreationUtils.CreateQueue($"{endpointName}.Timeouts", maxTimeToLive, queueNamePrefix)
            .ConfigureAwait(false);

            // retries queue
            if (includeRetries)
            {
                await QueueCreationUtils.CreateQueue($"{endpointName}.Retries", maxTimeToLive, queueNamePrefix)
                .ConfigureAwait(false);
            }
        }