Пример #1
0
        RoutingComponent InitializeRouting(TransportInfrastructure transportInfrastructure, ReceiveConfiguration receiveConfiguration)
        {
            // use GetOrCreate to use of instances already created during EndpointConfiguration.
            var routing = new RoutingComponent(
                settings.GetOrCreate <UnicastRoutingTable>(),
                settings.GetOrCreate <DistributionPolicy>(),
                settings.GetOrCreate <EndpointInstances>(),
                settings.GetOrCreate <Publishers>());

            routing.Initialize(settings, transportInfrastructure.ToTransportAddress, pipelineComponent.PipelineSettings, receiveConfiguration);

            return(routing);
        }
        public async Task <IStartableEndpoint> Initialize()
        {
            RegisterCriticalErrorHandler();
            var concreteTypes = settings.GetAvailableTypes()
                                .Where(IsConcrete)
                                .ToList();

            WireUpConfigSectionOverrides(concreteTypes);

            var featureActivator = BuildFeatureActivator(concreteTypes);

            ConfigRunBeforeIsFinalized(concreteTypes);

            var transportDefinition     = settings.Get <TransportDefinition>();
            var connectionString        = settings.Get <TransportConnectionString>().GetConnectionStringOrRaiseError(transportDefinition);
            var transportInfrastructure = transportDefinition.Initialize(settings, connectionString);

            settings.Set <TransportInfrastructure>(transportInfrastructure);

            // use GetOrCreate to use of instances already created during EndpointConfiguration.
            var routing = new RoutingComponent(
                settings.GetOrCreate <UnicastRoutingTable>(),
                settings.GetOrCreate <DistributionPolicy>(),
                settings.GetOrCreate <EndpointInstances>(),
                settings.GetOrCreate <Publishers>());

            routing.Initialize(settings, transportInfrastructure, pipelineSettings);

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

            pipelineConfiguration.RegisterBehaviorsInContainer(settings, container);

            DisplayDiagnosticsForFeatures.Run(featureStats);

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

            await RunInstallers(concreteTypes).ConfigureAwait(false);

            var startableEndpoint = new StartableEndpoint(settings, builder, featureActivator, pipelineConfiguration, new EventAggregator(settings.Get <NotificationSubscriptions>()), transportInfrastructure, criticalError);

            return(startableEndpoint);
        }
Пример #3
0
        void Initialize()
        {
            containerComponent.ContainerConfiguration.RegisterSingleton <ReadOnlySettings>(settings);

            RegisterCriticalErrorHandler();

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

            featureComponent = new FeatureComponent(settings);

            // This needs to happen here to make sure that features enabled state is present in settings so both
            // IWantToRunBeforeConfigurationIsFinalized implementations and transports can check access it
            featureComponent.RegisterFeatureEnabledStatusInSettings(concreteTypes);

            ConfigRunBeforeIsFinalized(concreteTypes);

            transportInfrastructure = InitializeTransportComponent();

            var receiveConfiguration = BuildReceiveConfiguration(transportInfrastructure);

            var routingComponent = new RoutingComponent(settings);

            routingComponent.Initialize(transportInfrastructure, pipelineComponent, receiveConfiguration);

            var messageMapper = new MessageMapper();

            settings.Set <IMessageMapper>(messageMapper);

            pipelineComponent.AddRootContextItem <IMessageMapper>(messageMapper);

            recoverabilityComponent = new RecoverabilityComponent(settings);

            var featureConfigurationContext = new FeatureConfigurationContext(settings, containerComponent.ContainerConfiguration, pipelineComponent.PipelineSettings, routingComponent, receiveConfiguration);

            featureComponent.Initalize(containerComponent, featureConfigurationContext);
            //The settings can only be locked after initializing the feature component since it uses the settings to store & share feature state.
            settings.PreventChanges();

            recoverabilityComponent.Initialize(receiveConfiguration);

            pipelineComponent.Initialize(containerComponent);
            containerComponent.ContainerConfiguration.ConfigureComponent(b => settings.Get <Notifications>(), DependencyLifecycle.SingleInstance);

            var eventAggregator = new EventAggregator(settings.Get <NotificationSubscriptions>());

            pipelineComponent.AddRootContextItem <IEventAggregator>(eventAggregator);

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

            if (shouldRunInstallers)
            {
                RegisterInstallers(concreteTypes);
            }

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

            queueBindings    = settings.Get <QueueBindings>();
            receiveComponent = CreateReceiveComponent(receiveConfiguration, transportInfrastructure, pipelineComponent, queueBindings, eventAggregator);
        }
Пример #4
0
        void Initialize()
        {
            var pipelineSettings = settings.Get <PipelineSettings>();

            hostingConfiguration.Container.RegisterSingleton <ReadOnlySettings>(settings);

            featureComponent = new FeatureComponent(settings);

            // This needs to happen here to make sure that features enabled state is present in settings so both
            // IWantToRunBeforeConfigurationIsFinalized implementations and transports can check access it
            featureComponent.RegisterFeatureEnabledStatusInSettings(hostingConfiguration);

            ConfigRunBeforeIsFinalized(hostingConfiguration);

            var transportConfiguration = TransportComponent.PrepareConfiguration(settings.Get <TransportComponent.Settings>());

            var receiveConfiguration = BuildReceiveConfiguration(transportConfiguration);

            var routingComponent = RoutingComponent.Initialize(
                settings.Get <RoutingComponent.Configuration>(),
                transportConfiguration,
                receiveConfiguration,
                settings.Get <Conventions>(),
                pipelineSettings);

            var messageMapper = new MessageMapper();

            settings.Set <IMessageMapper>(messageMapper);

            recoverabilityComponent = new RecoverabilityComponent(settings);

            var featureConfigurationContext = new FeatureConfigurationContext(settings, hostingConfiguration.Container, pipelineSettings, routingComponent, receiveConfiguration);

            featureComponent.Initalize(featureConfigurationContext);

            hostingConfiguration.CreateHostInformationForV7BackwardsCompatibility();

            recoverabilityComponent.Initialize(receiveConfiguration, hostingConfiguration);

            sendComponent = SendComponent.Initialize(pipelineSettings, hostingConfiguration, routingComponent, messageMapper);

            pipelineComponent = PipelineComponent.Initialize(pipelineSettings, hostingConfiguration);

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

            receiveComponent = ReceiveComponent.Initialize(
                settings.Get <ReceiveComponent.Configuration>(),
                receiveConfiguration,
                transportConfiguration,
                pipelineComponent,
                settings.ErrorQueueAddress(),
                hostingConfiguration,
                pipelineSettings);

            installationComponent = InstallationComponent.Initialize(settings.Get <InstallationComponent.Configuration>(),
                                                                     hostingConfiguration);

            // The settings can only be locked after initializing the feature component since it uses the settings to store & share feature state.
            // As well as all the other components have been initialized
            settings.PreventChanges();

            transportComponent = TransportComponent.Initialize(transportConfiguration, hostingConfiguration);

            settings.AddStartupDiagnosticsSection("Endpoint",
                                                  new
            {
                Name               = settings.EndpointName(),
                SendOnly           = settings.Get <bool>("Endpoint.SendOnly"),
                NServiceBusVersion = GitVersionInformation.MajorMinorPatch
            }
                                                  );
        }
Пример #5
0
        public static SendComponent Initialize(PipelineSettings pipelineSettings, HostingComponent.Configuration hostingConfiguration, RoutingComponent routingComponent, IMessageMapper messageMapper)
        {
            pipelineSettings.Register(new AttachSenderRelatedInfoOnMessageBehavior(), "Makes sure that outgoing messages contains relevant info on the sending endpoint.");
            pipelineSettings.Register("AuditHostInformation", new AuditHostInformationBehavior(hostingConfiguration.HostInformation, hostingConfiguration.EndpointName), "Adds audit host information");
            pipelineSettings.Register("AddHostInfoHeaders", new AddHostInfoHeadersBehavior(hostingConfiguration.HostInformation, hostingConfiguration.EndpointName), "Adds host info headers to outgoing headers");

            pipelineSettings.Register("UnicastSendRouterConnector", new SendConnector(routingComponent.UnicastSendRouter), "Determines how the message being sent should be routed");
            pipelineSettings.Register("UnicastReplyRouterConnector", new ReplyConnector(), "Determines how replies should be routed");


            pipelineSettings.Register(new OutgoingPhysicalToRoutingConnector(), "Starts the message dispatch pipeline");
            pipelineSettings.Register(new RoutingToDispatchConnector(), "Decides if the current message should be batched or immediately be dispatched to the transport");
            pipelineSettings.Register(new BatchToDispatchConnector(), "Passes batched messages over to the immediate dispatch part of the pipeline");
            pipelineSettings.Register(b => new ImmediateDispatchTerminator(b.GetRequiredService <IMessageDispatcher>()), "Hands the outgoing messages over to the transport for immediate delivery");

            var sendComponent = new SendComponent(messageMapper);

            return(sendComponent);
        }
Пример #6
0
        void Configure()
        {
            ConfigureMessageTypes();

            var pipelineSettings = settings.Get <PipelineSettings>();

            hostingConfiguration.Services.AddSingleton(typeof(ReadOnlySettings), settings);

            featureComponent = new FeatureComponent(settings);

            // This needs to happen here to make sure that features enabled state is present in settings so both
            // IWantToRunBeforeConfigurationIsFinalized implementations and transports can check access it
            featureComponent.RegisterFeatureEnabledStatusInSettings(hostingConfiguration);

            transportSeam = TransportSeam.Create(settings.Get <TransportSeam.Settings>(), hostingConfiguration);

            var receiveConfiguration = ReceiveComponent.PrepareConfiguration(
                hostingConfiguration,
                settings.Get <ReceiveComponent.Settings>(),
                transportSeam);

            var routingConfiguration = RoutingComponent.Configure(settings.Get <RoutingComponent.Settings>());

            var messageMapper = new MessageMapper();

            settings.Set <IMessageMapper>(messageMapper);

            recoverabilityComponent = new RecoverabilityComponent(settings);

            var featureConfigurationContext = new FeatureConfigurationContext(settings, hostingConfiguration.Services, pipelineSettings, routingConfiguration, receiveConfiguration);

            featureComponent.Initalize(featureConfigurationContext);

            recoverabilityComponent.Initialize(receiveConfiguration, hostingConfiguration, transportSeam);

            var routingComponent = RoutingComponent.Initialize(
                routingConfiguration,
                transportSeam,
                receiveConfiguration,
                settings.Get <Conventions>(),
                pipelineSettings);

            sendComponent = SendComponent.Initialize(pipelineSettings, hostingConfiguration, routingComponent, messageMapper);

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

            receiveComponent = ReceiveComponent.Configure(
                receiveConfiguration,
                settings.ErrorQueueAddress(),
                hostingConfiguration,
                pipelineSettings);

            pipelineComponent = PipelineComponent.Initialize(pipelineSettings, hostingConfiguration);

            // The settings can only be locked after initializing the feature component since it uses the settings to store & share feature state.
            // As well as all the other components have been initialized
            settings.PreventChanges();

            // The pipeline settings can be locked after the endpoint is configured. It prevents end users from modyfing pipeline after an endpoint has started.
            pipelineSettings.PreventChanges();

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