void InitializeIfNecessary()
        {
            if (Interlocked.Exchange(ref initializeSignaled, 1) != 0)
            {
                return;
            }

            Guard.AgainstUnsetSerializerSetting(Settings);

            var sendOnly = Settings.GetOrDefault <bool>("Endpoint.SendOnly");
            var localAddressForSendOnlyEndpoint = ToTransportAddress(LogicalAddress.CreateLocalAddress(Settings.EndpointName(), new Dictionary <string, string>()));

            try
            {
                localAddress = sendOnly ? localAddressForSendOnlyEndpoint : Settings.LocalAddress();
            }
            catch
            {
                // For tests other than Acceptance tests, LocalAddress() will throw
                localAddress = localAddressForSendOnlyEndpoint;
            }

            defaultNamespaceAlias        = Settings.Get <string>(WellKnownConfigurationKeys.Topology.Addressing.DefaultNamespaceAlias);
            namespaceConfigurations      = Settings.Get <NamespaceConfigurations>(WellKnownConfigurationKeys.Topology.Addressing.Namespaces);
            messageSizePaddingPercentage = Settings.Get <int>(WellKnownConfigurationKeys.Connectivity.MessageSenders.MessageSizePaddingPercentage);

            var partitioningStrategyType = (Type)Settings.Get(WellKnownConfigurationKeys.Topology.Addressing.Partitioning.Strategy);

            partitioningStrategy = partitioningStrategyType.CreateInstance <INamespacePartitioningStrategy>(Settings);

            namespaceManager = new NamespaceManagerLifeCycleManagerInternal(new NamespaceManagerCreator(Settings));
            messagingFactoryLifeCycleManager = new MessagingFactoryLifeCycleManager(new MessagingFactoryCreator(namespaceManager, Settings), Settings);

            messageReceiverLifeCycleManager = new MessageReceiverLifeCycleManager(new MessageReceiverCreator(messagingFactoryLifeCycleManager, Settings), Settings);
            senderLifeCycleManager          = new MessageSenderLifeCycleManager(new MessageSenderCreator(messagingFactoryLifeCycleManager, Settings), Settings);

            oversizedMessageHandler = (IHandleOversizedBrokeredMessages)Settings.Get(WellKnownConfigurationKeys.Connectivity.MessageSenders.OversizedBrokeredMessageHandlerInstance);

            topologyManager  = CreateTopologySectionManager(defaultNamespaceAlias, namespaceConfigurations, partitioningStrategy, addressingLogic);
            topologyCreator  = new TopologyCreator(CreateSubscriptionCreator(), new AzureServiceBusQueueCreator(TopologySettings.QueueSettings, Settings), new AzureServiceBusTopicCreator(TopologySettings.TopicSettings), namespaceManager, Settings);
            topologyOperator = new TopologyOperator(messageReceiverLifeCycleManager, new BrokeredMessagesToIncomingMessagesConverter(Settings, new DefaultConnectionStringToNamespaceAliasMapper(Settings)), Settings);
        }
 public TransportResourcesCreator(TopologyCreator topologyCreator, ITopologySectionManagerInternal sections, string localAddress)
 {
     this.topologyCreator = topologyCreator;
     this.sections        = sections;
     this.localAddress    = localAddress;
 }
Exemple #3
0
 public SubscriptionManager(ITopologySectionManagerInternal topologySectionManager, IOperateTopologyInternal topologyOperator, TopologyCreator topologyCreator, string localAddress)
 {
     this.topologySectionManager = topologySectionManager;
     this.topologyOperator       = topologyOperator;
     this.topologyCreator        = topologyCreator;
     this.localAddress           = localAddress;
 }