public void SetUp() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace(PrimaryName, PrimaryConnectionString); extensions.NamespacePartitioning().AddNamespace(SecondaryName, SecondaryConnectionString); strategy = new FailOverNamespacePartitioning(settings); }
public void Single_partitioning_strategy_will_throw_if_more_namespaces_defined() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace(Name, ConnectionString); extensions.NamespacePartitioning().AddNamespace(OtherName, OtherConnectionString); Assert.Throws <ConfigurationErrorsException>(() => new SingleNamespacePartitioning(settings)); }
public void Failover_partitioning_strategy_will_throw_if_more_than_primary_and_secondary_namespaces_are_provided() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace(PrimaryName, PrimaryConnectionString); extensions.NamespacePartitioning().AddNamespace(SecondaryName, SecondaryConnectionString); extensions.NamespacePartitioning().AddNamespace(OtherName, OtherConnectionString); Assert.Throws <ConfigurationErrorsException>(() => new FailOverNamespacePartitioning(settings)); }
public void SetUp() { settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace(PrimaryName, PrimaryConnectionString); extensions.NamespacePartitioning().AddNamespace(SecondaryName, SecondaryConnectionString); namespacePartitioningStrategy = new RoundRobinNamespacePartitioning(settings); // apply entity maximum lengths for addressing logic settings.SetDefault(WellKnownConfigurationKeys.Topology.Addressing.Sanitization.QueuePathMaximumLength, 260); settings.SetDefault(WellKnownConfigurationKeys.Topology.Addressing.Sanitization.TopicPathMaximumLength, 260); settings.SetDefault(WellKnownConfigurationKeys.Topology.Addressing.Sanitization.SubscriptionNameMaximumLength, 50); settings.SetDefault(WellKnownConfigurationKeys.Topology.Addressing.Sanitization.RuleNameMaximumLength, 50); }
public void Determines_there_should_be_a_topic_bundle_created() { var container = new TransportPartsContainer(); var settings = new SettingsHolder(); container.Register(typeof(SettingsHolder), () => settings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var topology = new ForwardingTopology(container); topology.Initialize(settings); var sectionManager = container.Resolve <ITopologySectionManager>(); var definition = sectionManager.DetermineResourcesToCreate(new QueueBindings()); var result = definition.Entities.Where(ei => ei.Type == EntityType.Topic && ei.Namespace.ConnectionString == Connectionstring && ei.Path.StartsWith("bundle-")); Assert.That(result.Count(), Is.EqualTo(2)); Assert.That(result, Has.Exactly(1).Matches <EntityInfo>(x => x.Path == "bundle-1")); Assert.That(result, Has.Exactly(1).Matches <EntityInfo>(x => x.Path == "bundle-2")); }
ITopologySectionManager SetupForwardingTopologyWithFailoverNamespace(TransportPartsContainer container, string enpointname) { var settings = new SettingsHolder(); container.Register(typeof(SettingsHolder), () => settings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", enpointname); extensions.NamespacePartitioning().AddNamespace("namespace1", AzureServiceBusConnectionString.Value); extensions.NamespacePartitioning().AddNamespace("namespace2", AzureServiceBusConnectionString.Fallback); extensions.NamespacePartitioning().UseStrategy <FailOverNamespacePartitioning>(); var topology = new ForwardingTopology(container); topology.Initialize(settings); return(container.Resolve <ITopologySectionManager>()); }
public void SetUp() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace(Name, ConnectionString); strategy = new SingleNamespacePartitioning(settings); }
public void Should_be_able_to_extend_namespace_partitioning_settings() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var partitioningSettings = extensions.NamespacePartitioning(); Assert.IsInstanceOf <AzureServiceBusNamespacePartitioningSettings>(partitioningSettings); }
public void Should_be_able_to_set_the_partitioning_strategy() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var partitioningSettings = extensions.NamespacePartitioning().UseStrategy <MyNamespacePartitioningStrategy>(); Assert.AreEqual(typeof(MyNamespacePartitioningStrategy), partitioningSettings.GetSettings().Get <Type>(WellKnownConfigurationKeys.Topology.Addressing.Partitioning.Strategy)); }
public void Roundrobin_partitioning_strategy_will_throw_if_too_little_namespaces_are_provided() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace(PrimaryName, PrimaryConnectionString); Assert.Throws <ConfigurationErrorsException>(() => new RoundRobinNamespacePartitioning(settings)); }
public void Should_be_able_to_set_broker_side_subscription_filter_factory_instance() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var myCreateBrokerSideSubscriptionFilter = new MyCreateBrokerSideSubscriptionFilter(); var partitioningSettings = extensions.NamespacePartitioning().OverrideBrokerSideSubscriptionFilterFactory(myCreateBrokerSideSubscriptionFilter); Assert.AreEqual(myCreateBrokerSideSubscriptionFilter, partitioningSettings.GetSettings().Get(WellKnownConfigurationKeys.Topology.Addressing.Sanitization.BrokerSideSubscriptionFilterFactoryInstance)); }
public void Should_be_able_to_add_a_namespace() { const string connectionString = "Endpoint=sb://namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=somesecretkey"; const string name = "namespace1"; var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace(name, connectionString); var namespacesDefinition = settings.Get <NamespaceConfigurations>(WellKnownConfigurationKeys.Topology.Addressing.Namespaces); CollectionAssert.Contains(namespacesDefinition, new NamespaceInfo(name, connectionString)); }
public async Task Determines_there_should_be_a_topic_with_same_name_as_endpointname_followed_by_dot_events() { var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); settings.Set(new Conventions()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); settings.SetDefault("NServiceBus.SharedQueue", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var definition = await DetermineResourcesToCreate(settings); Assert.AreEqual(1, definition.Entities.Count(ei => ei.Path == "sales.events" && ei.Type == EntityType.Topic && ei.Namespace.ConnectionString == Connectionstring)); }
#pragma warning disable 618 ITopologySectionManager SetupEndpointOrientedTopology(TransportPartsContainer container, string enpointname) { var settings = new SettingsHolder(); settings.Set <Conventions>(new Conventions()); container.Register(typeof(SettingsHolder), () => settings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", enpointname); extensions.NamespacePartitioning().AddNamespace("namespace1", AzureServiceBusConnectionString.Value); var topology = new EndpointOrientedTopology(container); topology.Initialize(settings); return(container.Resolve <ITopologySectionManager>()); }
public void Determines_there_should_be_a_topic_with_same_name_as_endpointname_followed_by_dot_events() { var container = new TransportPartsContainer(); var settings = new SettingsHolder(); settings.Set <Conventions>(new Conventions()); container.Register(typeof(SettingsHolder), () => settings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var definition = DetermineResourcesToCreate(settings, container); Assert.AreEqual(1, definition.Entities.Count(ei => ei.Path == "sales.events" && ei.Type == EntityType.Topic && ei.Namespace.ConnectionString == Connectionstring)); }
public async Task Should_fail_sanitization_for_invalid_endpoint_name(string reasonToFail, string endpointName) { var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); settings.SetDefault("NServiceBus.SharedQueue", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var topology = new ForwardingTransportInfrastructure(settings); await topology.Start(); var sectionManager = topology.topologyManager; Assert.Throws <Exception>(() => sectionManager.DetermineQueuesToCreate(new QueueBindings(), endpointName), "Was expected to fail: " + reasonToFail); }
public async Task Determines_the_namespace_from_partitioning_strategy() { var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); settings.Set(new Conventions()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); settings.SetDefault("NServiceBus.SharedQueue", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var definition = await DetermineResourcesToCreate(settings); var namespaceInfo = new RuntimeNamespaceInfo(Name, Connectionstring); Assert.IsTrue(definition.Namespaces.Any(nsi => nsi == namespaceInfo)); }
public async Task Determines_there_should_be_a_queue_with_same_name_as_endpointname() { var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); settings.SetDefault("NServiceBus.SharedQueue", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var topology = new ForwardingTransportInfrastructure(settings); await topology.Start(); var sectionManager = topology.topologyManager; var definition = sectionManager.DetermineQueuesToCreate(new QueueBindings(), "sales"); Assert.AreEqual(1, definition.Entities.Count(ei => ei.Path == "sales" && ei.Type == EntityType.Queue && ei.Namespace.ConnectionString == Connectionstring)); }
public async Task Determines_the_namespace_from_partitioning_strategy() { var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); settings.SetDefault("NServiceBus.SharedQueue", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var topology = new ForwardingTransportInfrastructure(settings); await topology.Start(); var sectionManager = topology.topologyManager; var definition = sectionManager.DetermineQueuesToCreate(new QueueBindings(), "sales"); var namespaceInfo = new RuntimeNamespaceInfo(Name, Connectionstring); Assert.IsTrue(definition.Namespaces.Any(nsi => nsi == namespaceInfo)); }
public void Should_fail_sanitization_for_invalid_endpoint_name(string reasonToFail, string endpointName) { var container = new TransportPartsContainer(); var settings = new SettingsHolder(); container.Register(typeof(SettingsHolder), () => settings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", endpointName); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var topology = new ForwardingTopology(container); topology.Initialize(settings); var sectionManager = container.Resolve <ITopologySectionManager>(); Assert.Throws <Exception>(() => sectionManager.DetermineResourcesToCreate(new QueueBindings()), "Was expected to fail: " + reasonToFail); }
public void Determines_there_should_be_a_queue_with_same_name_as_endpointname() { var container = new TransportPartsContainer(); var settings = new SettingsHolder(); container.Register(typeof(SettingsHolder), () => settings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var topology = new ForwardingTopology(container); topology.Initialize(settings); var sectionManager = container.Resolve <ITopologySectionManager>(); var definition = sectionManager.DetermineResourcesToCreate(new QueueBindings()); Assert.AreEqual(1, definition.Entities.Count(ei => ei.Path == "sales" && ei.Type == EntityType.Queue && ei.Namespace.ConnectionString == Connectionstring)); }
public void Determines_the_namespace_from_partitioning_strategy() { var container = new TransportPartsContainer(); var settings = new SettingsHolder(); settings.Set <Conventions>(new Conventions()); container.Register(typeof(SettingsHolder), () => settings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var definition = DetermineResourcesToCreate(settings, container); // ReSharper disable once RedundantArgumentDefaultValue var namespaceInfo = new RuntimeNamespaceInfo(Name, Connectionstring); Assert.IsTrue(definition.Namespaces.Any(nsi => nsi == namespaceInfo)); }
async Task <ITopologySectionManager> SetupEndpointOrientedTopology(TransportPartsContainer container, string endpointName, SettingsHolder settings) { container.Register(typeof(SettingsHolder), () => settings); settings.SetDefault("NServiceBus.Routing.EndpointName", endpointName); settings.Set <Conventions>(new Conventions()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NamespacePartitioning().AddNamespace("namespaceName", AzureServiceBusConnectionString.Value); var endpointOrientedTopology = new EndpointOrientedTopology(container); endpointOrientedTopology.Initialize(settings); // create the topologySectionManager var topologyCreator = (ICreateTopology)container.Resolve(typeof(TopologyCreator)); var sectionManager = container.Resolve <ITopologySectionManager>(); await topologyCreator.Create(sectionManager.DetermineResourcesToCreate(new QueueBindings())); container.RegisterSingleton <TopologyOperator>(); return(sectionManager); }
public async Task Determines_there_should_be_a_topic_bundle_created() { var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); settings.SetDefault("NServiceBus.Routing.EndpointName", "sales"); settings.SetDefault("NServiceBus.SharedQueue", "sales"); extensions.NamespacePartitioning().AddNamespace(Name, Connectionstring); var topology = new ForwardingTransportInfrastructure(settings); await topology.Start(); var sectionManager = topology.topologyManager; sectionManager.DetermineQueuesToCreate(new QueueBindings(), "sales"); var definition = sectionManager.DetermineTopicsToCreate("sales"); var result = definition.Entities.Where(ei => ei.Type == EntityType.Topic && ei.Namespace.ConnectionString == Connectionstring && ei.Path.StartsWith("bundle-")); Assert.That(result.Count(), Is.EqualTo(1)); Assert.That(result, Has.Exactly(1).Matches <EntityInfoInternal>(x => x.Path == "bundle-1")); }