public static void Validate(DynamicHostControllerConfig cfg) { if (cfg == null) { return; } foreach (PropertyInformation property in cfg.ElementInformation.Properties) { if (property.ValueOrigin != PropertyValueOrigin.Default) { throw new NotSupportedException(BuildConfigExceptionMessage(property.Name)); } } }
public void Start() { DynamicHostControllerConfig configSection = null; var o = new BusConfiguration(); o.AssembliesToScan(GetType().Assembly); o.AzureConfigurationSource(); o.RegisterComponents(Configurer => { Configurer.ConfigureComponent <DynamicEndpointLoader>(DependencyLifecycle.SingleInstance); Configurer.ConfigureComponent <DynamicEndpointProvisioner>(DependencyLifecycle.SingleInstance); Configurer.ConfigureComponent <DynamicEndpointRunner>(DependencyLifecycle.SingleInstance); Configurer.ConfigureComponent <DynamicHostMonitor>(DependencyLifecycle.SingleInstance); configSection = o.GetSettings().GetConfigSection <DynamicHostControllerConfig>() ?? new DynamicHostControllerConfig(); Configurer.ConfigureProperty <DynamicEndpointLoader>(t => t.ConnectionString, configSection.ConnectionString); Configurer.ConfigureProperty <DynamicEndpointLoader>(t => t.Container, configSection.Container); Configurer.ConfigureProperty <DynamicEndpointProvisioner>(t => t.LocalResource, configSection.LocalResource); Configurer.ConfigureProperty <DynamicEndpointProvisioner>(t => t.RecycleRoleOnError, configSection.RecycleRoleOnError); Configurer.ConfigureProperty <DynamicEndpointRunner>(t => t.RecycleRoleOnError, configSection.RecycleRoleOnError); Configurer.ConfigureProperty <DynamicEndpointRunner>(t => t.TimeToWaitUntilProcessIsKilled, configSection.TimeToWaitUntilProcessIsKilled); Configurer.ConfigureProperty <DynamicHostMonitor>(t => t.Interval, configSection.UpdateInterval); }); o.UsePersistence <AzureStoragePersistence>(); o.DiscardFailedMessagesInsteadOfSendingToErrorQueue(); profileManager.ActivateProfileHandlers(o); specifier.Customize(o); var bus = (UnicastBus)Bus.CreateSendOnly(o); loader = bus.Builder.Build <DynamicEndpointLoader>(); provisioner = bus.Builder.Build <DynamicEndpointProvisioner>(); runner = bus.Builder.Build <DynamicEndpointRunner>(); var endpointsToHost = loader.LoadEndpoints(); if (endpointsToHost == null) { return; } runningServices = new List <EndpointToHost>(endpointsToHost); provisioner.Provision(runningServices); runner.Start(runningServices); if (!configSection.AutoUpdate) { return; } monitor = bus.Builder.Build <DynamicHostMonitor>(); monitor.UpdatedEndpoints += UpdatedEndpoints; monitor.NewEndpoints += NewEndpoints; monitor.RemovedEndpoints += RemovedEndpoints; monitor.Monitor(runningServices); monitor.Start(); }