Ejemplo n.º 1
0
        public async Task PrepareToStart(ContainerComponent containerComponent, RecoverabilityComponent recoverabilityComponent)
        {
            if (IsSendOnly)
            {
                return;
            }

            mainPipelineExecutor = new MainPipelineExecutor(containerComponent.Builder, pipeline);

            if (configuration.PurgeOnStartup)
            {
                Logger.Warn("All queues owned by the endpoint will be purged on startup.");
            }

            AddReceivers(containerComponent.Builder, recoverabilityComponent.GetRecoverabilityExecutorFactory(containerComponent.Builder));

            foreach (var receiver in receivers)
            {
                try
                {
                    await receiver.Init().ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    Logger.Fatal($"Receiver {receiver.Id} failed to initialize.", ex);
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Defines a custom builder to use.
        /// </summary>
        /// <param name="definitionType">The type of the <see cref="ContainerDefinition" />.</param>
        public void UseContainer(Type definitionType)
        {
            Guard.AgainstNull(nameof(definitionType), definitionType);
            Guard.TypeHasDefaultConstructor(definitionType, nameof(definitionType));

            ContainerComponent.UseContainer(definitionType);
        }
Ejemplo n.º 3
0
        public static HostingComponent Initialize(Configuration configuration,
                                                  ContainerComponent containerComponent,
                                                  PipelineSettings pipelineSettings)
        {
            var hostingComponent = new HostingComponent(configuration);

            containerComponent.ContainerConfiguration.ConfigureComponent(() => hostingComponent.HostInformation, DependencyLifecycle.SingleInstance);

            pipelineSettings.Register("AuditHostInformation", new AuditHostInformationBehavior(hostingComponent.HostInformation, configuration.EndpointName), "Adds audit host information");
            pipelineSettings.Register("AddHostInfoHeaders", new AddHostInfoHeadersBehavior(hostingComponent.HostInformation, configuration.EndpointName), "Adds host info headers to outgoing headers");


            hostingComponent.AddStartupDiagnosticsSection("Hosting", new
            {
                hostingComponent.HostInformation.HostId,
                HostDisplayName = hostingComponent.HostInformation.DisplayName,
                RuntimeEnvironment.MachineName,
                OSPlatform = Environment.OSVersion.Platform,
                OSVersion  = Environment.OSVersion.VersionString,
                GCSettings.IsServerGC,
                GCLatencyMode = GCSettings.LatencyMode,
                Environment.ProcessorCount,
                Environment.Is64BitProcess,
                CLRVersion = Environment.Version,
                Environment.WorkingSet,
                Environment.SystemPageSize,
                HostName = Dns.GetHostName(),
                Environment.UserName,
                PathToExe = PathUtilities.SanitizedPath(Environment.CommandLine)
            });

            return(hostingComponent);
        }
Ejemplo n.º 4
0
 EndpointCreator(SettingsHolder settings,
                 ContainerComponent containerComponent,
                 PipelineComponent pipelineComponent)
 {
     this.settings           = settings;
     this.containerComponent = containerComponent;
     this.pipelineComponent  = pipelineComponent;
 }
Ejemplo n.º 5
0
        public void Initalize(ContainerComponent containerComponent, FeatureConfigurationContext featureConfigurationContext)
        {
            container = containerComponent;

            var featureStats = featureActivator.SetupFeatures(featureConfigurationContext);

            settings.AddStartupDiagnosticsSection("Features", featureStats);
        }
Ejemplo n.º 6
0
 public RunningEndpointInstance(SettingsHolder settings, ContainerComponent containerComponent, ReceiveComponent receiveComponent, FeatureComponent featureComponent, IMessageSession messageSession, TransportComponent transportComponent)
 {
     this.settings           = settings;
     this.containerComponent = containerComponent;
     this.receiveComponent   = receiveComponent;
     this.featureComponent   = featureComponent;
     this.messageSession     = messageSession;
     this.transportComponent = transportComponent;
 }
Ejemplo n.º 7
0
 public StartableEndpoint(SettingsHolder settings, ContainerComponent containerComponent, FeatureComponent featureComponent, TransportInfrastructure transportInfrastructure, ReceiveComponent receiveComponent, CriticalError criticalError, IMessageSession messageSession, RecoverabilityComponent recoverabilityComponent)
 {
     this.criticalError           = criticalError;
     this.settings                = settings;
     this.containerComponent      = containerComponent;
     this.featureComponent        = featureComponent;
     this.transportInfrastructure = transportInfrastructure;
     this.receiveComponent        = receiveComponent;
     this.messageSession          = messageSession;
     this.recoverabilityComponent = recoverabilityComponent;
 }
Ejemplo n.º 8
0
        public void Initialize(ContainerComponent containerComponent)
        {
            container = containerComponent;

            foreach (var registeredBehavior in modifications.Replacements)
            {
                container.ContainerConfiguration.ConfigureComponent(registeredBehavior.BehaviorType, DependencyLifecycle.InstancePerCall);
            }

            foreach (var step in modifications.Additions)
            {
                step.ApplyContainerRegistration(container.ContainerConfiguration);
            }
        }
Ejemplo n.º 9
0
        public static PipelineComponent Initialize(PipelineSettings settings, ContainerComponent containerComponent)
        {
            var modifications = settings.modifications;

            foreach (var registeredBehavior in modifications.Replacements)
            {
                containerComponent.ContainerConfiguration.ConfigureComponent(registeredBehavior.BehaviorType, DependencyLifecycle.InstancePerCall);
            }

            foreach (var step in modifications.Additions)
            {
                step.ApplyContainerRegistration(containerComponent.ContainerConfiguration);
            }

            return(new PipelineComponent(modifications));
        }
Ejemplo n.º 10
0
 public StartableEndpoint(SettingsHolder settings,
                          ContainerComponent containerComponent,
                          FeatureComponent featureComponent,
                          TransportComponent transportComponent,
                          ReceiveComponent receiveComponent,
                          CriticalError criticalError,
                          PipelineComponent pipelineComponent,
                          RecoverabilityComponent recoverabilityComponent,
                          HostingComponent hostingComponent)
 {
     this.criticalError           = criticalError;
     this.settings                = settings;
     this.containerComponent      = containerComponent;
     this.featureComponent        = featureComponent;
     this.transportComponent      = transportComponent;
     this.receiveComponent        = receiveComponent;
     this.pipelineComponent       = pipelineComponent;
     this.recoverabilityComponent = recoverabilityComponent;
     this.hostingComponent        = hostingComponent;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes the endpoint configuration builder.
        /// </summary>
        /// <param name="endpointName">The name of the endpoint being configured.</param>
        public EndpointConfiguration(string endpointName)
            : base(new SettingsHolder())
        {
            ValidateEndpointName(endpointName);

            Settings.Set(new InstallationComponent.Configuration(Settings));
            Settings.Set(new HostingComponent.Configuration(Settings));
            Settings.Set(new TransportComponent.Configuration(Settings));
            Settings.Set(Pipeline = new PipelineSettings(Settings));

            Settings.Set("NServiceBus.Routing.EndpointName", endpointName);

            ContainerComponent = new ContainerComponent(Settings);

            Settings.SetDefault("Endpoint.SendOnly", false);
            Settings.SetDefault("Transactions.IsolationLevel", IsolationLevel.ReadCommitted);
            Settings.SetDefault("Transactions.DefaultTimeout", TransactionManager.DefaultTimeout);

            Notifications = new Notifications();
            Settings.Set(Notifications);
            Settings.Set(new NotificationSubscriptions());

            ConventionsBuilder = new ConventionsBuilder(Settings);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Defines a custom builder to use.
 /// </summary>
 /// <typeparam name="T">The builder type of the <see cref="ContainerDefinition" />.</typeparam>
 public void UseContainer <T>(Action <ContainerCustomizations> customizations = null) where T : ContainerDefinition, new()
 {
     ContainerComponent.UseContainer <T>(customizations);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Used to configure components in the container.
        /// </summary>
        public void RegisterComponents(Action <IConfigureComponents> registration)
        {
            Guard.AgainstNull(nameof(registration), registration);

            ContainerComponent.AddUserRegistration(registration);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Uses an already active instance of a builder.
        /// </summary>
        /// <param name="builder">The instance to use.</param>
        public void UseContainer(IContainer builder)
        {
            Guard.AgainstNull(nameof(builder), builder);

            ContainerComponent.UseContainer(builder);
        }
Ejemplo n.º 15
0
        public static InstallationComponent Initialize(Configuration configuration, List <Type> concreteTypes, ContainerComponent containerComponent, TransportComponent transportComponent)
        {
            var component = new InstallationComponent(configuration, containerComponent, transportComponent);

            if (!configuration.ShouldRunInstallers)
            {
                return(component);
            }

            foreach (var installerType in concreteTypes.Where(t => IsINeedToInstallSomething(t)))
            {
                containerComponent.ContainerConfiguration.ConfigureComponent(installerType, DependencyLifecycle.InstancePerCall);
            }

            return(component);
        }
Ejemplo n.º 16
0
 InstallationComponent(Configuration configuration, ContainerComponent containerComponent, TransportComponent transportComponent)
 {
     this.configuration      = configuration;
     this.containerComponent = containerComponent;
     this.transportComponent = transportComponent;
 }