public async Task Should_be_able_to_create_partitioned_topic_with_multiple_rules() { const string subscriber = "subscriber"; const string filter1 = @"[x] LIKE 'x%'"; const string filter2 = @"[y] LIKE 'y%'"; var metadata2 = new ForwardingTopologySubscriptionMetadata { Description = "endpoint blah", NamespaceInfo = new RuntimeNamespaceInfo("name", AzureServiceBusConnectionString.Value), SubscribedEventFullName = "event2.full.name", SubscriptionNameBasedOnEventWithNamespace = "sha1.of.event2.full.name" }; var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.UseForwardingTopology().Topics().EnablePartitioning(true); var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); var creator = new AzureServiceBusForwardingSubscriptionCreator(new TopologySubscriptionSettings()); // add subscription with one rule await creator.Create(topicPath, subscriber, metadata, filter1, namespaceManager, forwardToQueue); // add additional rule to the same subscription var subscriptionDescription = await creator.Create(topicPath, subscriber, metadata2, filter2, namespaceManager, forwardToQueue); var rules = await namespaceManager.GetRules(subscriptionDescription); Assert.That(rules.Count(), Is.EqualTo(2), "Subscription didn't have correct number of rules"); await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriber)); }
public async Task Should_be_idempotent_when_creating_a_subscription() { var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.UseForwardingTopology().Subscriptions().DescriptionCustomizer(description => { description.MaxDeliveryCount = 100; description.EnableDeadLetteringOnMessageExpiration = true; }); var creator = new AzureServiceBusForwardingSubscriptionCreator(settings.Get <TopologySettings>().SubscriptionSettings); await creator.Create(topicPath, "someendpoint", metadata, sqlFilter, namespaceManager, forwardToQueue); await creator.Create(topicPath, "someendpoint", metadata, sqlFilter, namespaceManager, forwardToQueue); var rules = await namespaceManager.GetRules(new SubscriptionDescription(topicPath, "someendpoint")); Assert.AreEqual(1, rules.Count()); }
public async Task Should_create_subscription_with_sql_filter() { const string subscriber = "subscriber"; const string filter = @"[NServiceBus.EnclosedMessageTypes] LIKE 'Test.SomeEvent%'" + " OR [NServiceBus.EnclosedMessageTypes] LIKE '%Test.SomeEvent%'" + " OR [NServiceBus.EnclosedMessageTypes] LIKE '%Test.SomeEvent'" + " OR [NServiceBus.EnclosedMessageTypes] = 'Test.SomeEvent'"; var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); var creator = new AzureServiceBusForwardingSubscriptionCreator(new TopologySubscriptionSettings()); var subscriptionDescription = await creator.Create(topicPath, subscriber, metadata, filter, namespaceManager, forwardToQueue); var rules = await namespaceManager.GetRules(subscriptionDescription); var foundFilter = rules.First().Filter as SqlFilter; Assert.IsTrue(rules.Count() == 1, "Subscription should only have 1 rule"); Assert.AreEqual(filter, foundFilter.SqlExpression, "Rule was expected to have a specific SQL filter, but it didn't"); await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriber)); }