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>(); }
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); }
static void ValidateMasterNodeAddress(ReadOnlySettings settings) { var masterNodeName = MasterNodeConfiguration.GetMasterNode(settings); if (masterNodeName == null) { throw new ConfigurationErrorsException( "When defining Worker profile, 'MasterNodeConfig' section must be defined and the 'Node' entry should point to a valid host name."); } switch (IsLocalIpAddress(masterNodeName)) { case true: throw new ConfigurationErrorsException(string.Format("'MasterNodeConfig.Node' points to a local host name: [{0}]", masterNodeName)); case false: logger.InfoFormat("'MasterNodeConfig.Node' points to a non-local valid host name: [{0}].", masterNodeName); break; case null: throw new ConfigurationErrorsException( string.Format("'MasterNodeConfig.Node' entry should point to a valid host name. Currently it is: [{0}].", masterNodeName)); } }