public void Should_be_able_to_set_subscription_description_factory_method()
        {
            Action <SubscriptionDescription> registeredFactory = sd => { };

            extensions.Subscriptions().DescriptionCustomizer(registeredFactory);

            Assert.AreEqual(registeredFactory, settings.Get <TopologySettings>().SubscriptionSettings.DescriptionCustomizer);
        }
        public async Task Should_properly_set_ForwardDeadLetteredMessagesTo_on_the_created_entity_that_qualifies_the_condition()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);

            var topicCreator     = new AzureServiceBusTopicCreator(new TopologyTopicSettings());
            var topicToForwardTo = await topicCreator.Create("topic2forward2", namespaceManager);

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

            extensions.Subscriptions().ForwardDeadLetteredMessagesTo(subPath => subPath.EndsWith("/sub14"), topicToForwardTo.Path);

            var creator = new AzureServiceBusSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings);

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

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

            Assert.That(foundDescription.ForwardDeadLetteredMessagesTo.EndsWith(topicToForwardTo.Path));

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

            await namespaceManager.DeleteTopic(topicToForwardTo.Path);
        }
        public async Task Should_be_able_to_update_an_existing_subscription_with_new_property_values()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);
            //cleanup
            await namespaceManager.DeleteTopic("sometopic1");

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

            await namespaceManager.CreateSubscription(new SubscriptionDescription("sometopic1", "existingsubscription1"), sqlFilter);

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

            extensions.Subscriptions().DescriptionCustomizer(description =>
            {
                description.LockDuration = TimeSpan.FromSeconds(100);
                description.EnableDeadLetteringOnMessageExpiration = true;
            });

            var creator = new AzureServiceBusSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings);
            await creator.Create("sometopic1", "existingsubscription1", metadata, sqlFilter, namespaceManager);

            var subscriptionDescription = await namespaceManager.GetSubscription("sometopic1", "existingsubscription1");

            Assert.AreEqual(TimeSpan.FromSeconds(100), subscriptionDescription.LockDuration);
        }
        public async Task Should_be_able_to_update_an_existing_subscription_with_new_property_values_without_failing_on_readonly_properties()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value), AzureServiceBusConnectionString.Value);
            await namespaceManager.CreateTopic(new TopicDescription("sometopic2"));

            await namespaceManager.CreateSubscription(new SubscriptionDescription("sometopic2", "existingsubscription2")
            {
                EnableDeadLetteringOnFilterEvaluationExceptions = true,
                RequiresSession = true,
            }, "1=1");

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

            extensions.Subscriptions().DescriptionCustomizer(description =>
            {
                description.EnableDeadLetteringOnFilterEvaluationExceptions = false;
                description.RequiresSession = false;
            });

            var creator = new AzureServiceBusSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings);
            var subscriptionDescription = await creator.Create("sometopic2", "existingsubscription2", metadata, sqlFilter, namespaceManager);

            Assert.IsTrue(subscriptionDescription.RequiresSession);

            //cleanup
            await namespaceManager.DeleteTopic("sometopic2");
        }
        public async Task Should_properly_set_ForwardDeadLetteredMessagesTo_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapter(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            var topicCreator     = new AzureServiceBusTopicCreator(new DefaultConfigurationValues().Apply(new SettingsHolder()));
            var topicToForwardTo = await topicCreator.Create("topic2forward2", namespaceManager);


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

            extensions.Subscriptions().ForwardDeadLetteredMessagesTo(topicToForwardTo.Path);

            var creator = new AzureServiceBusSubscriptionCreator(settings);

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

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

            Assert.That(foundDescription.ForwardDeadLetteredMessagesTo.EndsWith(topicToForwardTo.Path));

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

            await namespaceManager.DeleteTopic(topicToForwardTo.Path);
        }
        public void Should_be_able_to_extend_subscription_settings()
        {
            var settings   = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            var subscriptionSettings = extensions.Subscriptions();

            Assert.IsInstanceOf <AzureServiceBusSubscriptionSettings>(subscriptionSettings);
        }
Пример #7
0
        public void Should_be_able_to_set_EnableDeadLetteringOnMessageExpiration()
        {
            var setting    = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(setting);

            var subscriptionSettings = extensions.Subscriptions().EnableDeadLetteringOnMessageExpiration(true);

            Assert.IsTrue(subscriptionSettings.GetSettings().Get <bool>(WellKnownConfigurationKeys.Topology.Resources.Subscriptions.EnableDeadLetteringOnMessageExpiration));
        }
Пример #8
0
        public void Should_be_able_to_set_ForwardDeadLetteredMessagesTo()
        {
            var setting    = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(setting);

            var subscriptionSettings = extensions.Subscriptions().ForwardDeadLetteredMessagesTo("deadletteredmessages");

            Assert.AreEqual("deadletteredmessages", subscriptionSettings.GetSettings().Get <string>(WellKnownConfigurationKeys.Topology.Resources.Subscriptions.ForwardDeadLetteredMessagesTo));
        }
Пример #9
0
        public void Should_be_able_to_set_LockDuration()
        {
            var setting    = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(setting);

            var lockDuration         = TimeSpan.FromDays(1);
            var subscriptionSettings = extensions.Subscriptions().LockDuration(lockDuration);

            Assert.AreEqual(lockDuration, subscriptionSettings.GetSettings().Get <TimeSpan>(WellKnownConfigurationKeys.Topology.Resources.Subscriptions.LockDuration));
        }
Пример #10
0
        public void Should_be_able_to_set_DefaultMessageTimeToLive()
        {
            var setting    = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(setting);

            var expiryTimespan       = TimeSpan.FromDays(1);
            var subscriptionSettings = extensions.Subscriptions().DefaultMessageTimeToLive(expiryTimespan);

            Assert.AreEqual(expiryTimespan, subscriptionSettings.GetSettings().Get <TimeSpan>(WellKnownConfigurationKeys.Topology.Resources.Subscriptions.DefaultMessageTimeToLive));
        }
Пример #11
0
        public void Should_be_able_to_set_AutoDeleteOnIdle()
        {
            var settings   = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            var idlePeriod    = TimeSpan.FromDays(10);
            var topicSettings = extensions.Subscriptions().AutoDeleteOnIdle(idlePeriod);

            Assert.AreEqual(idlePeriod, topicSettings.GetSettings().Get <TimeSpan>(WellKnownConfigurationKeys.Topology.Resources.Subscriptions.AutoDeleteOnIdle));
        }
Пример #12
0
        public void Should_be_able_to_set_MaxDeliveryCount()
        {
            var setting    = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(setting);

            const int selectedMaxDeliveryCount = 6;
            var       subscriptionSettings     = extensions.Subscriptions().MaxDeliveryCount(selectedMaxDeliveryCount);

            Assert.AreEqual(selectedMaxDeliveryCount, subscriptionSettings.GetSettings().Get <int>(WellKnownConfigurationKeys.Topology.Resources.Subscriptions.MaxDeliveryCount));
        }
Пример #13
0
        public void Should_be_able_to_set_subscription_description_factory_method()
        {
            var settings   = new SettingsHolder();
            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            Func <string, string, ReadOnlySettings, SubscriptionDescription> registeredFactory = (topicname, subscriptionname, s) => new SubscriptionDescription(topicname, subscriptionname);

            var connectivitySettings = extensions.Subscriptions().DescriptionFactory(registeredFactory);

            Assert.AreEqual(registeredFactory, connectivitySettings.GetSettings().Get <Func <string, string, ReadOnlySettings, SubscriptionDescription> >(WellKnownConfigurationKeys.Topology.Resources.Subscriptions.DescriptionFactory));
        }
Пример #14
0
        public static void ConfigureTransport(this TransportExtensions <AzureServiceBusTransport> transport, TransportSettings transportSettings)
        {
            transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
            transport.ConnectionString(transportSettings.ConnectionString);

            transport.MessageReceivers().PrefetchCount(0);
            transport.Queues().LockDuration(TimeSpan.FromMinutes(5));
            transport.Subscriptions().LockDuration(TimeSpan.FromMinutes(5));
            transport.MessagingFactories().NumberOfMessagingFactoriesPerNamespace(2);
            transport.NumberOfClientsPerEntity(Math.Min(Environment.ProcessorCount, transportSettings.MaxConcurrency));
        }
Пример #15
0
#pragma warning disable 618
        public static void ConfigureTransport(this TransportExtensions <AzureServiceBusTransport> transport, TransportSettings transportSettings, TransportTransactionMode transactionMode)
#pragma warning restore 618
        {
            //If the custom part stays in the connection string and is at the end, the sdk will treat is as part of the SharedAccessKey
            var connectionString = ConnectionStringPartRemover.Remove(transportSettings.ConnectionString, QueueLengthProvider.QueueLengthQueryIntervalPartName);

            transport.ConnectionString(connectionString);
            transport.Transactions(transactionMode);
            transport.Queues().LockDuration(TimeSpan.FromMinutes(5));
            transport.Subscriptions().LockDuration(TimeSpan.FromMinutes(5));
            transport.MessagingFactories().NumberOfMessagingFactoriesPerNamespace(2);
            transport.NumberOfClientsPerEntity(Math.Min(Environment.ProcessorCount, transportSettings.MaxConcurrency));
        }
        public async Task Should_properly_set_EnableDeadLetteringOnFilterEvaluationExceptions_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);

            extensions.Subscriptions().EnableDeadLetteringOnFilterEvaluationExceptions(true);

            var creator = new AzureServiceBusSubscriptionCreator(settings);

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

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

            Assert.IsTrue(foundDescription.EnableDeadLetteringOnFilterEvaluationExceptions);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName));
        }
        public async Task Should_properly_set_EnableDeadLetteringOnMessageExpiration_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.Subscriptions().EnableDeadLetteringOnMessageExpiration(true);

            var creator = new AzureServiceBusSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings);

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

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

            Assert.IsTrue(foundDescription.EnableDeadLetteringOnMessageExpiration);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName));
        }
        public async Task Should_properly_set_AutoDeleteOnIdle_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);

            var autoDeleteTime = TimeSpan.FromDays(1);

            extensions.Subscriptions().AutoDeleteOnIdle(autoDeleteTime);

            var creator = new AzureServiceBusSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings);

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

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

            Assert.AreEqual(autoDeleteTime, foundDescription.AutoDeleteOnIdle);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName));
        }
        public async Task Should_properly_set_MaxDeliveryCount_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);

            const int deliveryCount = 10;

            extensions.Subscriptions().MaxDeliveryCount(deliveryCount);

            var creator = new AzureServiceBusSubscriptionCreator(settings);

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

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

            Assert.AreEqual(deliveryCount, foundDescription.MaxDeliveryCount);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName));
        }
        public async Task Should_properly_set_use_subscription_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 subscriptionName        = "sub2";
            var          subscriptionDescription = new SubscriptionDescription(topicPath, subscriptionName)
            {
                LockDuration = TimeSpan.FromMinutes(3)
            };

            extensions.Subscriptions().DescriptionFactory((x, y, z) => subscriptionDescription);

            var creator = new AzureServiceBusSubscriptionCreator(settings);

            var foundDescription = await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager);

            Assert.IsTrue(await namespaceManager.SubscriptionExists(topicPath, subscriptionName));
            Assert.AreEqual(subscriptionDescription, foundDescription);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName));
        }
        public async Task Should_properly_set_use_subscription_description_provided_by_user()
        {
            var settings         = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());
            var extensions       = new TransportExtensions <AzureServiceBusTransport>(settings);
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            const string subscriptionName = "endpoint2";

            var userCustomizationsWhereInvoked = false;

            extensions.Subscriptions().DescriptionCustomizer(_ =>
            {
                userCustomizationsWhereInvoked = true;
            });

            var creator = new AzureServiceBusForwardingSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings);

            await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager, forwardToQueue);

            Assert.IsTrue(await namespaceManager.SubscriptionExists(topicPath, subscriptionName));
            Assert.IsTrue(userCustomizationsWhereInvoked);

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