internal WorkerNode()
        {
            Defaults(s => s.Set("Worker.Enabled", true));
            Defaults(s =>
            {
                var masterNodeAddress = MasterNodeConfiguration.GetMasterNodeAddress(s);
                s.Set("MasterNode.Address", masterNodeAddress);
                s.Set("PublicReturnAddress", masterNodeAddress);

                if (!string.IsNullOrEmpty(MasterNodeConfiguration.GetMasterNode(s)))
                {
                    s.SetDefault("SecondLevelRetries.AddressOfRetryProcessor", masterNodeAddress.SubScope("Retries"));
                }
            });
            Defaults(s =>
            {
                var workerName = ConfigurationManager.AppSettings.Get("NServiceBus/Distributor/WorkerNameToUseWhileTesting");

                if (!String.IsNullOrEmpty(workerName))
                {
                    s.Set("NServiceBus.LocalAddress", workerName);
                }
            });
            RegisterStartupTask <ReadyMessageSender>();
        }
Пример #2
0
        public DistributorReadyMessageProcessor(IBuilder builder, ReadOnlySettings settings)
        {
            disable = !settings.GetOrDefault <bool>("Distributor.Enabled");

            if (disable)
            {
                return;
            }

            workerAvailabilityManager = builder.Build <IWorkerAvailabilityManager>();
            address = MasterNodeConfiguration.GetMasterNodeAddress(settings).SubScope("distributor.control");
        }
        public DistributorSatellite(IBuilder builder, ReadOnlySettings settings)
        {
            disable = !settings.GetOrDefault <bool>("Distributor.Enabled");

            if (disable)
            {
                return;
            }

            messageSender = builder.Build <ISendMessages>();
            workerManager = builder.Build <IWorkerAvailabilityManager>();
            address       = MasterNodeConfiguration.GetMasterNodeAddress(settings);
        }
        /// <summary>
        /// Called when the features is activated
        /// </summary>
        protected override void Setup(FeatureConfigurationContext context)
        {
            if (!context.Settings.GetOrDefault <bool>("Distributor.Enabled"))
            {
                var workerName = ConfigurationManager.AppSettings.Get("NServiceBus/Distributor/WorkerNameToUseWhileTesting");

                if (String.IsNullOrEmpty(workerName))
                {
                    ValidateMasterNodeAddress(context.Settings);
                }
            }

            var masterNodeAddress = MasterNodeConfiguration.GetMasterNodeAddress(context.Settings);

            var distributorControlAddress = masterNodeAddress.SubScope("distributor.control");

            var unicastBusConfig = context.Settings.GetConfigSection <UnicastBusConfig>();

            //allow users to override control address in config
            if (unicastBusConfig != null && !string.IsNullOrWhiteSpace(unicastBusConfig.DistributorControlAddress))
            {
                distributorControlAddress = Address.Parse(unicastBusConfig.DistributorControlAddress);
            }

            if (!context.Container.HasComponent <WorkerQueueCreator>())
            {
                context.Container.ConfigureComponent <WorkerQueueCreator>(DependencyLifecycle.InstancePerCall)
                .ConfigureProperty(p => p.WorkerEnabled, true);
            }
            else
            {
                context.Container.ConfigureProperty <WorkerQueueCreator>(p => p.WorkerEnabled, true);
            }

            context.Container.ConfigureComponent <ReadyMessageSender>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.DistributorControlAddress, distributorControlAddress);
        }