Esempio n. 1
0
        public async Task Should_create_a_subscription_based_on_event_type_full_name_for_an_event_name_reused_across_multiple_namespaces()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.CreateSubscription(new SubscriptionDescription(topicPath, nameof(Ns1.ReusedEvent)), new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize());

            var creator   = new AzureServiceBusSubscriptionCreatorV6(new TopologySubscriptionSettings());
            var metadata1 = new SubscriptionMetadataInternal
            {
                SubscriptionNameBasedOnEventWithNamespace = typeof(Ns1.ReusedEvent).FullName,
                Description = Guid.NewGuid().ToString()
            };
            var metadata2 = new SubscriptionMetadataInternal
            {
                SubscriptionNameBasedOnEventWithNamespace = typeof(Ns2.ReusedEvent).FullName,
                Description = Guid.NewGuid().ToString()
            };
            var shortedSubscriptionName = typeof(Ns2.ReusedEvent).FullName;

            await creator.Create(topicPath, nameof(Ns1.ReusedEvent), metadata1, new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize(), namespaceManager);

            await creator.Create(topicPath, nameof(Ns2.ReusedEvent), metadata2, new SqlSubscriptionFilter(typeof(Ns2.ReusedEvent)).Serialize(), namespaceManager);

            var subscriptionDescription = await namespaceManager.GetSubscription(topicPath, shortedSubscriptionName);

            Assert.AreEqual(metadata2.Description, subscriptionDescription.UserMetadata);
            Assert.AreEqual(metadata2.SubscriptionNameBasedOnEventWithNamespace, subscriptionDescription.Name);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, nameof(Ns1.ReusedEvent)));

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, nameof(Ns2.ReusedEvent)));
        }
Esempio n. 2
0
        public async Task Should_properly_set_ForwardTo_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.CreateSubscription(new SubscriptionDescription(topicPath, nameof(Ns1.ReusedEvent)), new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize());

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

            var creator   = new AzureServiceBusSubscriptionCreatorV6(new TopologySubscriptionSettings());
            var metadata1 = new SubscriptionMetadataInternal
            {
                SubscriptionNameBasedOnEventWithNamespace = typeof(Ns1.ReusedEvent).FullName,
                Description = Guid.NewGuid().ToString()
            };

            var subscriptionName = nameof(Ns1.ReusedEvent);

            await creator.Create(topicPath, subscriptionName, metadata1, new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize(), namespaceManager, topicToForwardTo.Path);

            // create again without forward to
            await creator.Create(topicPath, subscriptionName, metadata1, new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize(), namespaceManager);

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

            Assert.IsNull(subscriptionDescription.ForwardTo);

            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_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_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));
            await namespaceManager.CreateSubscription(new SubscriptionDescription(topicPath, "existingendpoint2")
            {
                EnableDeadLetteringOnFilterEvaluationExceptions = true,
                RequiresSession = true
            }, "1=1");

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

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

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

            Assert.ThrowsAsync <ArgumentException>(async() => await creator.Create(topicPath, "existingendpoint2", metadata, sqlFilter, namespaceManager, forwardToQueue));
        }
        public async Task Should_be_able_to_update_an_existing_subscription_with_new_property_values()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.CreateSubscription(new SubscriptionDescription(topicPath, "existingendpoint1"), sqlFilter);

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

            extensions.UseForwardingTopology().Subscriptions().DescriptionCustomizer(description =>
            {
                description.LockDuration = TimeSpan.FromMinutes(5);
                description.EnableDeadLetteringOnMessageExpiration = true;
            });

            var creator = new AzureServiceBusForwardingSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings);
            await creator.Create(topicPath, "existingendpoint1", metadata, sqlFilter, namespaceManager, forwardToQueue);

            var subscriptionDescription = await namespaceManager.GetSubscription(topicPath, "existingendpoint1");

            Assert.AreEqual(TimeSpan.FromMinutes(5), subscriptionDescription.LockDuration);
            Assert.IsTrue(subscriptionDescription.EnableDeadLetteringOnMessageExpiration);
        }
Esempio n. 7
0
        public async Task Should_not_create_create_a_duplicate_subscription__issue_811()
        {
            var nativeManager    = NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value);
            var namespaceManager = new NamespaceManagerAdapterInternal(nativeManager);

            var topicForTest = $"{topicPath}_issue811";

            try
            {
                if (!await nativeManager.TopicExistsAsync(topicForTest))
                {
                    await nativeManager.CreateTopicAsync(new TopicDescription(topicForTest));
                }

                var subscriptionName = nameof(SomeEvent);

                await namespaceManager.CreateSubscription(new SubscriptionDescription(topicForTest, subscriptionName), new SqlSubscriptionFilter_UsedPriorToVersion9(typeof(SomeEvent)).Serialize());

                var creator  = new AzureServiceBusSubscriptionCreatorV6(new TopologySubscriptionSettings());
                var metadata = new SubscriptionMetadataInternal
                {
                    SubscriptionNameBasedOnEventWithNamespace = typeof(SomeEvent).FullName,
                    Description = Guid.NewGuid().ToString()
                };
                var properSqlFilter = new SqlSubscriptionFilter(typeof(SomeEvent)).Serialize();

                await creator.Create(topicForTest, subscriptionName, metadata, properSqlFilter, namespaceManager);

                var foundSubcriptions = await nativeManager.GetSubscriptionsAsync(topicForTest);

                Assert.AreEqual(1, foundSubcriptions.Count());
            }
            finally
            {
                await nativeManager.DeleteTopicAsync(topicForTest);
            }
        }