public async Task Should_not_update_properties_of_an_existing_system_queue()
        {
            var queuePath = "errorQ";

            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.DeleteQueue(queuePath).ConfigureAwait(false);

            if (!await namespaceManager.QueueExists(queuePath).ConfigureAwait(false))
            {
                await namespaceManager.CreateQueue(new QueueDescription(queuePath)).ConfigureAwait(false);
            }

            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            settings.Set(WellKnownConfigurationKeys.Core.RecoverabilityNumberOfImmediateRetries, 2);
            var queueBindings = new QueueBindings();

            queueBindings.BindSending(queuePath);
            settings.Set <QueueBindings>(queueBindings);

            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().LockDuration(TimeSpan.FromMinutes(4));

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create(queuePath, namespaceManager);

            var real = await namespaceManager.GetQueue(queuePath);

            Assert.That(real.LockDuration, Is.EqualTo(TimeSpan.FromSeconds(60)));

            //cleanup
            await namespaceManager.DeleteQueue(queuePath);
        }
        public async Task Properly_sets_ForwardDeadLetteredMessagesTo_on_the_created_entity_that_qualifies_condition()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);
            await creator.Create("myotherqueue", namespaceManager);

            extensions.Queues().ForwardDeadLetteredMessagesTo(name => name == "myqueue", "myotherqueue");
            await creator.Create("myqueue", namespaceManager);

            var real = await namespaceManager.GetQueue("myqueue");

            var forwardReal = await namespaceManager.GetQueue("myotherqueue");

            Assert.IsTrue(real.ForwardDeadLetteredMessagesTo.EndsWith("myotherqueue"));
            Assert.IsTrue(string.IsNullOrEmpty(forwardReal.ForwardDeadLetteredMessagesTo));

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");

            await namespaceManager.DeleteQueue("myotherqueue");
        }
        public async Task Properly_sets_ForwardDeadLetteredMessagesTo_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            // forwarding queue needs to exist before you can use it as a forwarding target
            // needs to be created with different settings as it cannot forward to itself obviously
            var originalsettings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());
            var originalcreator  = new AzureServiceBusQueueCreator(new TopologyQueueSettings(), originalsettings);
            await originalcreator.Create("myotherqueue", namespaceManager);

            // actual test
            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().ForwardDeadLetteredMessagesTo("myotherqueue");

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create("myqueue", namespaceManager);

            var real = await namespaceManager.GetQueue("myqueue");

            Assert.IsTrue(real.ForwardDeadLetteredMessagesTo.EndsWith("myotherqueue"));

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");

            await namespaceManager.DeleteQueue("myotherqueue");
        }
        public async Task Should_be_able_to_update_an_existing_queue_with_new_property_values()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.DeleteQueue("existingqueue").ConfigureAwait(false);

            await namespaceManager.CreateQueue(new QueueDescription("existingqueue"));

            var settings   = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());
            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().DescriptionCustomizer(qd =>
            {
                qd.AutoDeleteOnIdle = TimeSpan.FromMinutes(100);
                qd.EnableExpress    = true;
            });

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);
            await creator.Create("existingqueue", namespaceManager);

            var queueDescription = await namespaceManager.GetQueue("existingqueue");

            Assert.AreEqual(TimeSpan.FromMinutes(100), queueDescription.AutoDeleteOnIdle);

            //cleanup
            await namespaceManager.DeleteQueue("existingqueue");
        }
        public async Task Should_be_able_to_update_an_existing_queue_with_new_property_values_without_failing_on_readonly_properties()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.DeleteQueue("existingqueue").ConfigureAwait(false);

            await namespaceManager.CreateQueue(new QueueDescription("existingqueue")
            {
                LockDuration               = TimeSpan.FromSeconds(50),
                MaxSizeInMegabytes         = SizeInMegabytes.Size2048,
                RequiresDuplicateDetection = true,
                EnablePartitioning         = true,
                RequiresSession            = true
            });

            var queueDescription = await namespaceManager.GetQueue("existingqueue");

            // partitioned topics will have a size that is 16x the requested max
            Assert.AreEqual(2048 * 16, queueDescription.MaxSizeInMegabytes);
            Assert.AreEqual(TimeSpan.FromSeconds(50), queueDescription.LockDuration);
            Assert.IsTrue(queueDescription.EnablePartitioning);
            Assert.IsTrue(queueDescription.RequiresDuplicateDetection);

            var settings   = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());
            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().DescriptionCustomizer(qd =>
            {
                qd.LockDuration               = TimeSpan.FromSeconds(70);
                qd.MaxSizeInMegabytes         = SizeInMegabytes.Size3072;
                qd.RequiresDuplicateDetection = false;
                qd.EnablePartitioning         = false;
                qd.RequiresSession            = false;
            });

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);
            await creator.Create("existingqueue", namespaceManager);

            queueDescription = await namespaceManager.GetQueue("existingqueue");

            Assert.AreEqual(3072 * 16, queueDescription.MaxSizeInMegabytes);
            Assert.AreEqual(TimeSpan.FromSeconds(70), queueDescription.LockDuration);
            Assert.IsTrue(queueDescription.EnablePartitioning);
            Assert.IsTrue(queueDescription.RequiresDuplicateDetection);

            //cleanup
            await namespaceManager.DeleteQueue("existingqueue");
        }
        public void TopicCleanUp()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            namespaceManager.DeleteTopic(topicPath).GetAwaiter().GetResult();
            namespaceManager.DeleteQueue(forwardToQueue).GetAwaiter().GetResult();

            namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            namespaceManager.DeleteTopic(topicPath).GetAwaiter().GetResult();
            namespaceManager.DeleteQueue(forwardToQueue).GetAwaiter().GetResult();
        }
Beispiel #7
0
        public async Task Should_fail_over_to_available_namespace()
        {
            var namespaceManager1 = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(targetConnectionString), targetConnectionString);
            await namespaceManager1.DeleteQueue(Conventions.EndpointNamingConvention(typeof(TargetEndpoint)));

            var contextWithOnlyNamespace1Available = await Scenario.Define <Context>()
                                                     .WithEndpoint <SourceEndpoint>(b =>
            {
                b.When(async(bus, c) =>
                {
                    await bus.Send(new MyRequest());
                    await bus.Send(new MyRequest());
                    await bus.Send(new MyRequest());
                });
            })
                                                     .WithEndpoint <TargetEndpoint>(b => b.CustomConfig(c => c.ConfigureAzureServiceBus().ConnectionString(connectionString)))
                                                     .Done(c => c.RequestsReceived == 3 && c.NamespaceNames.Count == 3)
                                                     .Run();

            var namespaceManager2 = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(connectionString), targetConnectionString);
            await namespaceManager2.DeleteQueue(Conventions.EndpointNamingConvention(typeof(TargetEndpoint)));

            var contextWithOnlyNamespace2Available = await Scenario.Define <Context>()
                                                     .WithEndpoint <SourceEndpoint>(b =>
            {
                b.When(async(bus, c) =>
                {
                    await bus.Send(new MyRequest());
                    await bus.Send(new MyRequest());
                    await bus.Send(new MyRequest());
                });
            })
                                                     .WithEndpoint <TargetEndpoint>(b => b.CustomConfig(c => c.ConfigureAzureServiceBus().ConnectionString(targetConnectionString)))
                                                     .Done(c => c.RequestsReceived == 3 && c.NamespaceNames.Count == 3)
                                                     .Run();

            CollectionAssert.AreEquivalent(new[]
            {
                $"{Conventions.EndpointNamingConvention(typeof(TargetEndpoint))}@namespace1",
                $"{Conventions.EndpointNamingConvention(typeof(TargetEndpoint))}@namespace1",
                $"{Conventions.EndpointNamingConvention(typeof(TargetEndpoint))}@namespace1",
            }, contextWithOnlyNamespace1Available.NamespaceNames);
            CollectionAssert.AreEquivalent(new[]
            {
                $"{Conventions.EndpointNamingConvention(typeof(TargetEndpoint))}@namespace2",
                $"{Conventions.EndpointNamingConvention(typeof(TargetEndpoint))}@namespace2",
                $"{Conventions.EndpointNamingConvention(typeof(TargetEndpoint))}@namespace2",
            }, contextWithOnlyNamespace2Available.NamespaceNames);
        }
        public async Task Properly_sets_EnablePartitioning_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            //make sure any previously created queues with this name are removed as the EnablePartitioning cannot be updated
            await namespaceManager.DeleteQueue("myqueue");

            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().EnablePartitioning(true);

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create("myqueue", namespaceManager);

            var real = await namespaceManager.GetQueue("myqueue");

            Assert.IsTrue(real.EnablePartitioning);

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");
        }
        public async Task Should_set_MaxDeliveryCount_to_maximum()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create("myqueue", namespaceManager);

            var real = await namespaceManager.GetQueue("myqueue");

            Assert.That(real.MaxDeliveryCount, Is.EqualTo(AzureServiceBusQueueCreator.DefaultMaxDeliveryCountForNoImmediateRetries));

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");
        }
        public async Task Should_set_forwarding_to_an_explicitly_provided_forwardto()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);

            var queueCreator     = new AzureServiceBusQueueCreator(new TopologyQueueSettings(), DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()));
            var queueToForwardTo = await queueCreator.Create("forwardto", namespaceManager);

            var creator = new AzureServiceBusSubscriptionCreator(new TopologySubscriptionSettings());

            const string subscriptionName = "sub15";
            await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager, queueToForwardTo.Path);

            var foundDescription = await namespaceManager.GetSubscription(topicPath, subscriptionName);

            Assert.That(foundDescription.ForwardTo.EndsWith(queueToForwardTo.Path));

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName));

            await namespaceManager.DeleteQueue(queueToForwardTo.Path);
        }
        public async Task Properly_sets_LockDuration_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().LockDuration(TimeSpan.FromMinutes(5));

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create("myqueue", namespaceManager);

            var real = await namespaceManager.GetQueue("myqueue");

            Assert.AreEqual(TimeSpan.FromMinutes(5), real.LockDuration);

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");
        }
        public async Task Uses_queue_description_when_provided_by_user()
        {
            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var extensions       = new TransportExtensions <AzureServiceBusTransport>(settings);
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            var userQueueDescriptionFactoryWasInvoked = false;

            extensions.Queues().DescriptionCustomizer(qd => userQueueDescriptionFactoryWasInvoked = true);

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create("myqueue", namespaceManager);

            Assert.IsTrue(await namespaceManager.QueueExists("myqueue"));
            Assert.IsTrue(userQueueDescriptionFactoryWasInvoked);

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");
        }
Beispiel #13
0
        public async Task Properly_sets_EnableBatchedOperations_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);

            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().EnableBatchedOperations(false);

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create("myqueue", namespaceManager);

            var real = await namespaceManager.GetQueue("myqueue");

            Assert.IsFalse(real.EnableBatchedOperations);

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");
        }
        public async Task Should_properly_set_ForwardTo_on_the_created_entity_with_hierarchy()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);

            var queueCreator     = new AzureServiceBusQueueCreator(new TopologyQueueSettings(), DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()));
            var queueToForwardTo = await queueCreator.Create("forwardto", namespaceManager);

            var creator = new AzureServiceBusSubscriptionCreator(new TopologySubscriptionSettings());

            const string subscriptionName = "sub17";
            await creator.Create(hierarchyTopicPath, subscriptionName, metadata, sqlFilter, namespaceManager, queueToForwardTo.Path);

            // create again without forward to
            await creator.Create(hierarchyTopicPath, subscriptionName, metadata, sqlFilter, namespaceManager);

            var foundDescription = await namespaceManager.GetSubscription(hierarchyTopicPath, subscriptionName);

            Assert.IsNull(foundDescription.ForwardTo);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(hierarchyTopicPath, subscriptionName));

            await namespaceManager.DeleteQueue(queueToForwardTo.Path);
        }