Example #1
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);
        }
Example #2
0
 public StartableEndpoint(SettingsHolder settings,
                          FeatureComponent featureComponent,
                          ReceiveComponent receiveComponent,
                          TransportInfrastructure transportInfrastructure,
                          PipelineComponent pipelineComponent,
                          RecoverabilityComponent recoverabilityComponent,
                          HostingComponent hostingComponent,
                          SendComponent sendComponent,
                          IBuilder builder)
 {
     this.settings                = settings;
     this.featureComponent        = featureComponent;
     this.receiveComponent        = receiveComponent;
     this.transportInfrastructure = transportInfrastructure;
     this.pipelineComponent       = pipelineComponent;
     this.recoverabilityComponent = recoverabilityComponent;
     this.hostingComponent        = hostingComponent;
     this.sendComponent           = sendComponent;
     this.builder = builder;
 }
Example #3
0
 public StartableEndpoint(SettingsHolder settings,
                          FeatureComponent featureComponent,
                          ReceiveComponent receiveComponent,
                          TransportSeam transportSeam,
                          PipelineComponent pipelineComponent,
                          RecoverabilityComponent recoverabilityComponent,
                          HostingComponent hostingComponent,
                          SendComponent sendComponent,
                          IServiceProvider builder)
 {
     this.settings                = settings;
     this.featureComponent        = featureComponent;
     this.receiveComponent        = receiveComponent;
     this.transportSeam           = transportSeam;
     this.pipelineComponent       = pipelineComponent;
     this.recoverabilityComponent = recoverabilityComponent;
     this.hostingComponent        = hostingComponent;
     this.sendComponent           = sendComponent;
     this.builder = builder;
 }
Example #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
            }
                                                  );
        }
Example #5
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
            }
                                                  );
        }