示例#1
0
        public async Task <IEndpointInstance> Start()
        {
            await receiveComponent.ReceivePreStartupChecks().ConfigureAwait(false);

            await transportInfrastructure.Start().ConfigureAwait(false);

            // This is a hack to maintain the current order of transport infrastructure initialization
            sendComponent.ConfigureSendInfrastructureForBackwardsCompatibility();

            var pipelineCache     = pipelineComponent.BuildPipelineCache(builder);
            var messageOperations = sendComponent.CreateMessageOperations(builder, pipelineComponent);
            var rootContext       = new RootContext(builder, messageOperations, pipelineCache);
            var messageSession    = new MessageSession(rootContext);

            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

            await receiveComponent.PrepareToStart(builder, recoverabilityComponent, messageOperations, pipelineComponent, pipelineCache).ConfigureAwait(false);

            // This is a hack to maintain the current order of transport infrastructure initialization
            await sendComponent.InvokeSendPreStartupChecksForBackwardsCompatibility().ConfigureAwait(false);

            await featureComponent.Start(builder, messageSession).ConfigureAwait(false);

            var runningInstance = new RunningEndpointInstance(settings, hostingComponent, receiveComponent, featureComponent, messageSession, transportInfrastructure);

            await receiveComponent.Start().ConfigureAwait(false);

            return(runningInstance);
        }
示例#2
0
        public async Task <IEndpointInstance> Start()
        {
            await sendComponent.SendPreStartupChecks().ConfigureAwait(false);

            await receiveComponent.ReceivePreStartupChecks().ConfigureAwait(false);

            await transportInfrastructure.Start().ConfigureAwait(false);

            var pipelineCache     = pipelineComponent.BuildPipelineCache(builder);
            var messageOperations = sendComponent.CreateMessageOperations(builder, pipelineComponent);
            var rootContext       = new RootContext(builder, messageOperations, pipelineCache);
            var messageSession    = new MessageSession(rootContext);

#if NETSTANDARD
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            }
#else
            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
#endif
            await receiveComponent.PrepareToStart(builder, recoverabilityComponent, messageOperations, pipelineComponent, pipelineCache).ConfigureAwait(false);

            await featureComponent.Start(builder, messageSession).ConfigureAwait(false);

            var runningInstance = new RunningEndpointInstance(settings, hostingComponent, receiveComponent, featureComponent, messageSession, transportInfrastructure);

            await receiveComponent.Start().ConfigureAwait(false);

            return(runningInstance);
        }
示例#3
0
        public async Task <IEndpointInstance> Start()
        {
            await pipelineComponent.Start(containerComponent.Builder).ConfigureAwait(false);

            var messageSession = new MessageSession(pipelineComponent.CreateRootContext(containerComponent.Builder));

            await transportComponent.Start().ConfigureAwait(false);

            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

            await receiveComponent.PrepareToStart(containerComponent, recoverabilityComponent).ConfigureAwait(false);

            await featureComponent.Start(messageSession).ConfigureAwait(false);

            var runningInstance = new RunningEndpointInstance(settings, containerComponent, receiveComponent, featureComponent, messageSession, transportComponent);

            // set the started endpoint on CriticalError to pass the endpoint to the critical error action
            criticalError.SetEndpoint(runningInstance);

            await receiveComponent.Start().ConfigureAwait(false);

            await hostingComponent.Start().ConfigureAwait(false);

            return(runningInstance);
        }
示例#4
0
        public async Task <IEndpointInstance> Start(CancellationToken cancellationToken = default)
        {
            var transportInfrastructure = await transportSeam.CreateTransportInfrastructure(cancellationToken).ConfigureAwait(false);

            var pipelineCache       = pipelineComponent.BuildPipelineCache(builder);
            var messageOperations   = sendComponent.CreateMessageOperations(builder, pipelineComponent);
            var stoppingTokenSource = new CancellationTokenSource();

            var rootContext    = new RootContext(builder, messageOperations, pipelineCache, stoppingTokenSource.Token);
            var messageSession = new MessageSession(rootContext);

            await receiveComponent.Initialize(builder, recoverabilityComponent, messageOperations, pipelineComponent, pipelineCache, transportInfrastructure, cancellationToken).ConfigureAwait(false);

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            }

            await featureComponent.Start(builder, messageSession, cancellationToken).ConfigureAwait(false);

            var runningInstance = new RunningEndpointInstance(settings, hostingComponent, receiveComponent, featureComponent, messageSession, transportInfrastructure, stoppingTokenSource);

            await receiveComponent.Start(cancellationToken).ConfigureAwait(false);

            return(runningInstance);
        }
示例#5
0
        public async Task <IStartableEndpoint> Initialize()
        {
            RegisterCriticalErrorHandler();

            var concreteTypes = settings.GetAvailableTypes()
                                .Where(IsConcrete)
                                .ToList();

            var featureActivator = BuildFeatureActivator(concreteTypes);

            ConfigRunBeforeIsFinalized(concreteTypes);

            var transportInfrastructure = InitializeTransportComponent();

            var receiveConfiguration = BuildReceiveConfiguration(transportInfrastructure);

            var routing = InitializeRouting(transportInfrastructure, receiveConfiguration);

            var featureStats = featureActivator.SetupFeatures(container, pipelineSettings, routing, receiveConfiguration);

            settings.AddStartupDiagnosticsSection("Features", featureStats);

            pipelineConfiguration.RegisterBehaviorsInContainer(container);

            container.ConfigureComponent(b => settings.Get <Notifications>(), DependencyLifecycle.SingleInstance);

            var eventAggregator = new EventAggregator(settings.Get <NotificationSubscriptions>());
            var pipelineCache   = new PipelineCache(builder, settings);
            var queueBindings   = settings.Get <QueueBindings>();

            var receiveComponent = CreateReceiveComponent(receiveConfiguration, transportInfrastructure, queueBindings, pipelineCache, eventAggregator);

            var shouldRunInstallers = settings.GetOrDefault <bool>("Installers.Enable");

            if (shouldRunInstallers)
            {
                var username = GetInstallationUserName();

                if (settings.CreateQueues())
                {
                    await receiveComponent.CreateQueuesIfNecessary(queueBindings, username).ConfigureAwait(false);
                }

                await RunInstallers(concreteTypes, username).ConfigureAwait(false);
            }

            settings.AddStartupDiagnosticsSection("Endpoint",
                                                  new
            {
                Name               = settings.EndpointName(),
                SendOnly           = settings.Get <bool>("Endpoint.SendOnly"),
                NServiceBusVersion = GitFlowVersion.MajorMinorPatch
            }
                                                  );

            var messageSession = new MessageSession(new RootContext(builder, pipelineCache, eventAggregator));

            return(new StartableEndpoint(settings, builder, featureActivator, transportInfrastructure, receiveComponent, criticalError, messageSession));
        }
        public StartableEndpoint(SettingsHolder settings, IBuilder builder, FeatureActivator featureActivator, PipelineConfiguration pipelineConfiguration, IEventAggregator eventAggregator, TransportInfrastructure transportInfrastructure, CriticalError criticalError)
        {
            this.criticalError           = criticalError;
            this.settings                = settings;
            this.builder                 = builder;
            this.featureActivator        = featureActivator;
            this.pipelineConfiguration   = pipelineConfiguration;
            this.eventAggregator         = eventAggregator;
            this.transportInfrastructure = transportInfrastructure;

            pipelineCache = new PipelineCache(builder, settings);

            messageSession = new MessageSession(new RootContext(builder, pipelineCache, eventAggregator));
        }