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))); }
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_properly_set_ForwardDeadLetteredMessagesTo_on_the_created_entity_that_qualifies_the_condition() { var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); var topicCreator = new AzureServiceBusTopicCreator(new TopologyTopicSettings()); var notUsedEntity = await topicCreator.Create("topic2forward2", namespaceManager); var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.UseForwardingTopology().Subscriptions().ForwardDeadLetteredMessagesTo(subPath => subPath.EndsWith("endpoint14"), notUsedEntity.Path); var creator = new AzureServiceBusForwardingSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings); const string subscriptionName = "endpoint14"; await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager, forwardToQueue); var foundDescription = await namespaceManager.GetSubscription(topicPath, subscriptionName); Assert.That(foundDescription.ForwardDeadLetteredMessagesTo.EndsWith(notUsedEntity.Path)); await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName)); await namespaceManager.DeleteTopic(notUsedEntity.Path); }
public async Task Should_properly_set_AutoDeleteOnIdle_on_the_created_entity() { var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var autoDeleteTime = TimeSpan.FromDays(1); extensions.UseForwardingTopology().Subscriptions().AutoDeleteOnIdle(autoDeleteTime); var creator = new AzureServiceBusForwardingSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings); const string subscriptionName = "endpoint3"; await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager, forwardToQueue); var foundDescription = await namespaceManager.GetSubscription(topicPath, subscriptionName); // TODO: remove when ASB bug is fixed if (foundDescription.AutoDeleteOnIdle == TimeSpan.MaxValue) { Assert.Inconclusive("Microsoft ASB bug. Pending response from ASB group: https://www.yammer.com/azureadvisors/#/Threads/show?threadId=654972562"); } Assert.AreEqual(autoDeleteTime, foundDescription.AutoDeleteOnIdle); await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName)); }
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_properly_set_EnableDeadLetteringOnMessageExpiration_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.UseForwardingTopology().Subscriptions().EnableDeadLetteringOnMessageExpiration(true); var creator = new AzureServiceBusForwardingSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings); const string subscriptionName = "endpoint7"; await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager, forwardToQueue); var foundDescription = await namespaceManager.GetSubscription(topicPath, subscriptionName); Assert.IsTrue(foundDescription.EnableDeadLetteringOnMessageExpiration); await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName)); }
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 Should_properly_set_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.Subscriptions().EnableBatchedOperations(false); var creator = new AzureServiceBusSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings); const string subscriptionName = "sub5"; await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager); var foundDescription = await namespaceManager.GetSubscription(topicPath, subscriptionName); Assert.IsFalse(foundDescription.EnableBatchedOperations); await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName)); }
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); }
public async Task Should_properly_set_DefaultMessageTimeToLive_on_the_created_entity() { var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var timeToLive = TimeSpan.FromDays(10); extensions.Subscriptions().DefaultMessageTimeToLive(timeToLive); var creator = new AzureServiceBusSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings); const string subscriptionName = "sub4"; await creator.Create(topicPath, subscriptionName, metadata, sqlFilter, namespaceManager); var foundDescription = await namespaceManager.GetSubscription(topicPath, subscriptionName); Assert.AreEqual(timeToLive, foundDescription.DefaultMessageTimeToLive); await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName)); }
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); }