コード例 #1
0
        public void Preserves_FifoQueue(string destination, string expected)
        {
            var configuration = new TransportConfiguration(new SettingsHolder());

            var cache = new QueueCache(null, configuration);

            var result           = cache.GetPhysicalQueueName(destination);
            var resultIdempotent = cache.GetPhysicalQueueName(result);

            Assert.AreEqual(expected, result);
            Assert.AreEqual(expected, resultIdempotent);
        }
コード例 #2
0
        public void ReplacesNonDigitsWithDash(string destination, string expected)
        {
            var settings = new SettingsHolder();

            var configuration = new TransportConfiguration(settings);

            var cache = new QueueCache(null, configuration);

            var result           = cache.GetPhysicalQueueName(destination);
            var resultIdempotent = cache.GetPhysicalQueueName(result);

            Assert.AreEqual(expected, result);
            Assert.AreEqual(expected, resultIdempotent);
        }
コード例 #3
0
        public void Preserves_FifoQueue_WithPreTruncate(string destination, string expected)
        {
            var settings = new SettingsHolder();

            settings.Set(SettingsKeys.PreTruncateQueueNames, true);
            settings.Set(SettingsKeys.QueueNamePrefix, string.Empty);

            var configuration = new TransportConfiguration(settings);

            var cache = new QueueCache(null, configuration);

            var result           = cache.GetPhysicalQueueName(destination);
            var resultIdempotent = cache.GetPhysicalQueueName(result);

            Assert.AreEqual(expected, result);
            Assert.AreEqual(expected, resultIdempotent);
        }
コード例 #4
0
        public void ThrowsWhenLongerThanEightyChars(string destination, string queueNamePrefix)
        {
            var settings = new SettingsHolder();

            settings.Set(SettingsKeys.QueueNamePrefix, queueNamePrefix);

            var configuration = new TransportConfiguration(settings);

            var cache = new QueueCache(null, configuration);

            var exception = Assert.Throws <Exception>(() => cache.GetPhysicalQueueName(destination));

            Assert.That(exception.Message, Contains.Substring("is longer than 80 characters"));
        }
コード例 #5
0
        public static async Task <string> FindMatchingSubscription(this IAmazonSimpleNotificationService snsClient, QueueCache queueCache, Topic topic, string queueName)
        {
            var physicalQueueName = queueCache.GetPhysicalQueueName(queueName);

            ListSubscriptionsByTopicResponse upToAHundredSubscriptions = null;

            do
            {
                upToAHundredSubscriptions = await snsClient.ListSubscriptionsByTopicAsync(topic.TopicArn, upToAHundredSubscriptions?.NextToken)
                                            .ConfigureAwait(false);

                // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
                foreach (var upToAHundredSubscription in upToAHundredSubscriptions.Subscriptions)
                {
                    if (upToAHundredSubscription.Endpoint.EndsWith($":{physicalQueueName}", StringComparison.Ordinal))
                    {
                        return(upToAHundredSubscription.SubscriptionArn);
                    }
                }
            } while (upToAHundredSubscriptions.NextToken != null && upToAHundredSubscriptions.Subscriptions.Count > 0);

            return(null);
        }