public void Start() { if (specifier is IWantCustomInitialization) { try { (specifier as IWantCustomInitialization).Init(); } catch (NullReferenceException ex) { throw new NullReferenceException("NServiceBus has detected a null reference in your initalization code." + " This could be due to trying to use NServiceBus.Configure before it was ready." + " One possible solution is to inherit from IWantCustomInitialization in a different class" + " than the one that inherits from IConfigureThisEndpoint, and put your code there.", ex); } } if (Configure.Instance == null) { Configure.With(GetType().Assembly); } if (Configure.Instance.Configurer == null || Configure.Instance.Builder == null) { Configure.Instance.DefaultBuilder(); } Configure.Instance.AzureConfigurationSource(); Configure.Instance.Configurer.ConfigureComponent <DynamicEndpointLoader>(DependencyLifecycle.SingleInstance); Configure.Instance.Configurer.ConfigureComponent <DynamicEndpointProvisioner>(DependencyLifecycle.SingleInstance); Configure.Instance.Configurer.ConfigureComponent <DynamicEndpointRunner>(DependencyLifecycle.SingleInstance); Configure.Instance.Configurer.ConfigureComponent <DynamicHostMonitor>(DependencyLifecycle.SingleInstance); var configSection = Configure.GetConfigSection <DynamicHostControllerConfig>() ?? new DynamicHostControllerConfig(); Configure.Instance.Configurer.ConfigureProperty <DynamicEndpointLoader>(t => t.ConnectionString, configSection.ConnectionString); Configure.Instance.Configurer.ConfigureProperty <DynamicEndpointLoader>(t => t.Container, configSection.Container); Configure.Instance.Configurer.ConfigureProperty <DynamicEndpointProvisioner>(t => t.LocalResource, configSection.LocalResource); Configure.Instance.Configurer.ConfigureProperty <DynamicEndpointRunner>(t => t.RecycleRoleOnError, configSection.RecycleRoleOnError); Configure.Instance.Configurer.ConfigureProperty <DynamicEndpointRunner>(t => t.TimeToWaitUntilProcessIsKilled, configSection.TimeToWaitUntilProcessIsKilled); Configure.Instance.Configurer.ConfigureProperty <DynamicHostMonitor>(t => t.Interval, configSection.UpdateInterval); configManager.ConfigureCustomInitAndStartup(); profileManager.ActivateProfileHandlers(); loader = Configure.Instance.Builder.Build <DynamicEndpointLoader>(); provisioner = Configure.Instance.Builder.Build <DynamicEndpointProvisioner>(); runner = Configure.Instance.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 = Configure.Instance.Builder.Build <DynamicHostMonitor>(); monitor.UpdatedEndpoints += UpdatedEndpoints; monitor.NewEndpoints += NewEndpoints; monitor.RemovedEndpoints += RemovedEndpoints; monitor.Monitor(runningServices); monitor.Start(); }
public void Start() { if (specifier is IWantCustomInitialization) { try { (specifier as IWantCustomInitialization).Init(); } catch (NullReferenceException ex) { throw new NullReferenceException("NServiceBus has detected a null reference in your initalization code." + " This could be due to trying to use NServiceBus.Configure before it was ready." + " One possible solution is to inherit from IWantCustomInitialization in a different class" + " than the one that inherits from IConfigureThisEndpoint, and put your code there.", ex); } } if (Configure.Instance == null) Configure.With(GetType().Assembly); if (Configure.Instance.Configurer == null || Configure.Instance.Builder == null) Configure.Instance.DefaultBuilder(); Configure.Instance.AzureConfigurationSource(); Configure.Instance.Configurer.ConfigureComponent<DynamicEndpointLoader>(DependencyLifecycle.SingleInstance); Configure.Instance.Configurer.ConfigureComponent<DynamicEndpointProvisioner>(DependencyLifecycle.SingleInstance); Configure.Instance.Configurer.ConfigureComponent<DynamicEndpointRunner>(DependencyLifecycle.SingleInstance); Configure.Instance.Configurer.ConfigureComponent<DynamicHostMonitor>(DependencyLifecycle.SingleInstance); var configSection = Configure.GetConfigSection<DynamicHostControllerConfig>() ?? new DynamicHostControllerConfig(); Configure.Instance.Configurer.ConfigureProperty<DynamicEndpointLoader>(t => t.ConnectionString, configSection.ConnectionString); Configure.Instance.Configurer.ConfigureProperty<DynamicEndpointLoader>(t => t.Container, configSection.Container); Configure.Instance.Configurer.ConfigureProperty<DynamicEndpointProvisioner>(t => t.LocalResource, configSection.LocalResource); Configure.Instance.Configurer.ConfigureProperty<DynamicEndpointRunner>(t => t.RecycleRoleOnError, configSection.RecycleRoleOnError); Configure.Instance.Configurer.ConfigureProperty<DynamicEndpointRunner>(t => t.TimeToWaitUntilProcessIsKilled, configSection.TimeToWaitUntilProcessIsKilled); Configure.Instance.Configurer.ConfigureProperty<DynamicHostMonitor>(t => t.Interval, configSection.UpdateInterval); configManager.ConfigureCustomInitAndStartup(); profileManager.ActivateProfileHandlers(); loader = Configure.Instance.Builder.Build<DynamicEndpointLoader>(); provisioner = Configure.Instance.Builder.Build<DynamicEndpointProvisioner>(); runner = Configure.Instance.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 = Configure.Instance.Builder.Build<DynamicHostMonitor>(); monitor.UpdatedEndpoints += UpdatedEndpoints; monitor.NewEndpoints += NewEndpoints; monitor.RemovedEndpoints += RemovedEndpoints; monitor.Monitor(runningServices); monitor.Start(); }