public async Task Should_set_AutoDeleteOnIdle_on_the_created_entity()
        {
            var autoDeleteTime = TimeSpan.FromDays(1);

            var topologyTopicSettings = new TopologyTopicSettings
            {
                AutoDeleteOnIdle = autoDeleteTime
            };
            var creator = new AzureServiceBusTopicCreator(topologyTopicSettings);

            const string topicPath        = "mytopic4";
            var          namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);
            await namespaceManager.DeleteTopic(topicPath);

            await creator.Create(topicPath, namespaceManager);

            var foundTopic = await namespaceManager.GetTopic(topicPath);

            Assert.AreEqual(autoDeleteTime, foundTopic.AutoDeleteOnIdle);
        }
        public async Task Should_set_EnablePartitioning_on_created_entity()
        {
            var          namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);
            const string topicPath        = "mytopic9";

            //clean up before test starts
            await namespaceManager.DeleteTopic(topicPath);

            var topologyTopicSettings = new TopologyTopicSettings
            {
                EnablePartitioning = true
            };
            var creator = new AzureServiceBusTopicCreator(topologyTopicSettings);

            await creator.Create(topicPath, namespaceManager);

            var foundTopic = await namespaceManager.GetTopic(topicPath);

            Assert.IsTrue(foundTopic.EnablePartitioning);
        }
        public async Task Should_not_throw_when_another_node_creates_the_same_topic_first()
        {
            const string topicPath = "testtopic";

            var namespaceManager = A.Fake <INamespaceManagerInternal>();

            A.CallTo(() => namespaceManager.TopicExists(topicPath)).Returns(Task.FromResult(false));

            var topicCreationThrewException = false;

            A.CallTo(() => namespaceManager.CreateTopic(A <TopicDescription> .Ignored))
            .Invokes(() => topicCreationThrewException = true)
            .Throws(() => new MessagingEntityAlreadyExistsException("blah"));

            var creator = new AzureServiceBusTopicCreator(new TopologyTopicSettings());

            await creator.Create(topicPath, namespaceManager);

            Assert.IsTrue(topicCreationThrewException);
        }
        public async Task Should_use_topic_description_defaults_if_user_does_not_provide_topic_description_values()
        {
            var          namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);
            const string topicPath        = "mytopic2";
            await namespaceManager.DeleteTopic(topicPath);

            var creator          = new AzureServiceBusTopicCreator(new TopologyTopicSettings());
            var topicDescription = await creator.Create(topicPath, namespaceManager);

            Assert.IsTrue(await namespaceManager.TopicExists(topicPath));
            Assert.AreEqual(TimeSpan.MaxValue, topicDescription.AutoDeleteOnIdle);
            Assert.AreEqual(TimeSpan.MaxValue, topicDescription.DefaultMessageTimeToLive);
            Assert.AreEqual(TimeSpan.FromMilliseconds(600000), topicDescription.DuplicateDetectionHistoryTimeWindow);
            Assert.IsTrue(topicDescription.EnableBatchedOperations);
            Assert.IsFalse(topicDescription.EnableExpress);
            Assert.IsFalse(topicDescription.EnableFilteringMessagesBeforePublishing);
            Assert.IsFalse(topicDescription.EnablePartitioning);
            Assert.AreEqual(1024, topicDescription.MaxSizeInMegabytes);
            Assert.IsFalse(topicDescription.RequiresDuplicateDetection);
            Assert.IsFalse(topicDescription.SupportOrdering);
        }
Exemple #5
0
        public async Task Should_set_DefaultMessageTimeToLive_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapter(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

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

            var timeToLive = TimeSpan.FromDays(1);

            extensions.Topics().DefaultMessageTimeToLive(timeToLive);

            var          creator   = new AzureServiceBusTopicCreator(settings);
            const string topicPath = "mytopic5";
            await namespaceManager.DeleteTopic(topicPath);

            await creator.Create(topicPath, namespaceManager);

            var foundTopic = await namespaceManager.GetTopic(topicPath);

            Assert.AreEqual(timeToLive, foundTopic.DefaultMessageTimeToLive);
        }
Exemple #6
0
        public async Task Should_set_EnablePartitioning_on_created_entity()
        {
            var          namespaceManager = new NamespaceManagerAdapter(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            const string topicPath        = "mytopic9";

            //clean up before test starts
            await namespaceManager.DeleteTopic(topicPath);

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

            extensions.Topics().EnablePartitioning(true);

            var creator = new AzureServiceBusTopicCreator(settings);

            await creator.Create(topicPath, namespaceManager);

            var foundTopic = await namespaceManager.GetTopic(topicPath);

            Assert.IsTrue(foundTopic.EnablePartitioning);
        }
        public async Task Should_set_correct_defaults()
        {
            var          creator          = new AzureServiceBusTopicCreator(new TopologyTopicSettings());
            const string topicPath        = "mytopic13";
            var          namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);
            await namespaceManager.DeleteTopic(topicPath);

            await creator.Create(topicPath, namespaceManager);

            var foundTopic = await namespaceManager.GetTopic(topicPath);

            Assert.AreEqual(TimeSpan.MaxValue, foundTopic.AutoDeleteOnIdle);
            Assert.AreEqual(TimeSpan.MaxValue, foundTopic.DefaultMessageTimeToLive);
            Assert.AreEqual(TimeSpan.FromMinutes(10), foundTopic.DuplicateDetectionHistoryTimeWindow);
            Assert.IsTrue(foundTopic.EnableBatchedOperations);
            Assert.IsFalse(foundTopic.EnableExpress);
            Assert.IsFalse(foundTopic.EnableFilteringMessagesBeforePublishing);
            Assert.IsFalse(foundTopic.EnablePartitioning);
            Assert.AreEqual((long)SizeInMegabytes.Size1024, foundTopic.MaxSizeInMegabytes);
            Assert.IsFalse(foundTopic.RequiresDuplicateDetection);
            Assert.IsFalse(foundTopic.SupportOrdering);
        }
Exemple #8
0
        public async Task Should_be_able_to_update_an_existing_topic_with_new_property_values_without_failing_on_readonly_properties()
        {
            var namespaceManager = new NamespaceManagerAdapter(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.DeleteTopic("existingtopic2");

            await namespaceManager.CreateTopic(new TopicDescription("existingtopic2")
            {
                MaxSizeInMegabytes         = SizeInMegabytes.Size2048,
                RequiresDuplicateDetection = true,
                EnablePartitioning         = true
            });

            var topicDescription = await namespaceManager.GetTopic("existingtopic2");

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

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

            extensions.Topics().DescriptionFactory((queuePath, readOnlySettings) => new TopicDescription(queuePath)
            {
                MaxSizeInMegabytes         = SizeInMegabytes.Size3072,
                RequiresDuplicateDetection = false,
                EnablePartitioning         = false
            });

            var creator = new AzureServiceBusTopicCreator(settings);
            await creator.Create("existingtopic2", namespaceManager);

            topicDescription = await namespaceManager.GetTopic("existingtopic2");

            Assert.AreEqual(3072 * 16, topicDescription.MaxSizeInMegabytes);
            Assert.IsTrue(topicDescription.EnablePartitioning);
            Assert.IsTrue(topicDescription.RequiresDuplicateDetection);
        }
Exemple #9
0
        public async Task Should_use_topic_description_provided_by_user()
        {
            var settings         = new DefaultConfigurationValues().Apply(new SettingsHolder());
            var extensions       = new TransportExtensions <AzureServiceBusTransport>(settings);
            var namespaceManager = new NamespaceManagerAdapter(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            const string topicPath = "mytopic3";
            await namespaceManager.DeleteTopic(topicPath);

            var topicDescriptionToUse = new TopicDescription(topicPath)
            {
                AutoDeleteOnIdle = TimeSpan.MaxValue
            };

            extensions.Topics().DescriptionFactory((path, s) => topicDescriptionToUse);

            var creator = new AzureServiceBusTopicCreator(settings);

            var description = await creator.Create(topicPath, namespaceManager);

            Assert.IsTrue(await namespaceManager.TopicExists(topicPath));
            Assert.AreEqual(topicDescriptionToUse, description);
        }
Exemple #10
0
        public async Task Should_be_able_to_update_an_existing_topic_with_new_property_values()
        {
            var namespaceManager = new NamespaceManagerAdapter(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.DeleteTopic("existingtopic1");

            await namespaceManager.CreateTopic(new TopicDescription("existingtopic1"));

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

            extensions.Topics().DescriptionFactory((topicPath, readOnlySettings) => new TopicDescription(topicPath)
            {
                AutoDeleteOnIdle = TimeSpan.FromMinutes(100),
                EnableExpress    = true
            });

            var creator = new AzureServiceBusTopicCreator(settings);
            await creator.Create("existingtopic1", namespaceManager);

            var topicDescription = await namespaceManager.GetTopic("existingtopic1");

            Assert.AreEqual(TimeSpan.FromMinutes(100), topicDescription.AutoDeleteOnIdle);
        }