protected override ITopologySectionManagerInternal CreateTopologySectionManager(string defaultAlias, NamespaceConfigurations namespaces, INamespacePartitioningStrategy partitioning, AddressingLogic addressing) { var endpointName = Settings.EndpointName(); var numberOfEntitiesInBundle = Settings.Get <int>(WellKnownConfigurationKeys.Topology.Bundling.NumberOfEntitiesInBundle); bundlePrefix = Settings.Get <string>(WellKnownConfigurationKeys.Topology.Bundling.BundlePrefix); topologySectionManager = new ForwardingTopologySectionManager(defaultAlias, namespaces, endpointName, numberOfEntitiesInBundle, bundlePrefix, partitioning, addressing); // By design the topology section manager should determine the resources to create without needing information // from ASB. When we realized one bundle was enough we had to call out for backward compatibility reasons to query // how many bundles there are. This is async but should happen outside the actual section manager. Thus // the callback was introduced. topologySectionManager.Initialize = async() => { if (Interlocked.Exchange(ref initializeSignaled, 1) != 0) { return; } var bundleConfigurations = await NumberOfTopicsInBundleCheck.Run(namespaceManager, namespaceConfigurations, bundlePrefix) .ConfigureAwait(false); topologySectionManager.BundleConfigurations = bundleConfigurations; }; return(topologySectionManager); }
public void Should_alternate_between_namespaces_for_ForwardingTopologySectionManager_for_sending() { var namespaceConfigurations = new NamespaceConfigurations(); var addressingLogic = new AddressingLogic(new ThrowOnFailedValidation(settings), new FlatComposition()); var sectionManager = new ForwardingTopologySectionManager(PrimaryName, namespaceConfigurations, "sales", 1, "bundle", namespacePartitioningStrategy, addressingLogic); sectionManager.BundleConfigurations = new NamespaceBundleConfigurations { { PrimaryName, 1 }, { SecondaryName, 1 } }; sectionManager.DetermineSendDestination($"sales@{PrimaryName}"); var publishDestination2 = sectionManager.DetermineSendDestination($"sales@{PrimaryName}"); Assert.AreEqual(SecondaryName, publishDestination2.Entities.First().Namespace.Alias, "Should have different namespace"); }