예제 #1
0
 public RunningEndpointInstance(SettingsHolder settings, IBuilder builder, ReceiveComponent receiveComponent, FeatureRunner featureRunner, IMessageSession messageSession, TransportInfrastructure transportInfrastructure)
 {
     this.settings                = settings;
     this.builder                 = builder;
     this.receiveComponent        = receiveComponent;
     this.featureRunner           = featureRunner;
     this.messageSession          = messageSession;
     this.transportInfrastructure = transportInfrastructure;
 }
예제 #2
0
        public static ReceiveComponent Initialize(ReceiveConfiguration receiveConfiguration,
                                                  TransportComponent transportComponent,
                                                  PipelineComponent pipeline,
                                                  EventAggregator eventAggregator,
                                                  CriticalError criticalError,
                                                  string errorQueue,
                                                  HostingComponent hostingComponent)
        {
            Func <IPushMessages> messagePumpFactory = null;

            //we don't need the message pump factory for send-only endpoints
            if (receiveConfiguration != null)
            {
                messagePumpFactory = transportComponent.GetMessagePumpFactory();
            }

            var receiveComponent = new ReceiveComponent(receiveConfiguration,
                                                        messagePumpFactory,
                                                        pipeline,
                                                        eventAggregator,
                                                        criticalError,
                                                        errorQueue);

            receiveComponent.BindQueues(transportComponent.QueueBindings);

            if (receiveConfiguration != null)
            {
                hostingComponent.AddStartupDiagnosticsSection("Receiving", new
                {
                    receiveConfiguration.LocalAddress,
                    receiveConfiguration.InstanceSpecificQueue,
                    receiveConfiguration.LogicalAddress,
                    receiveConfiguration.PurgeOnStartup,
                    receiveConfiguration.QueueNameBase,
                    TransactionMode = receiveConfiguration.TransactionMode.ToString("G"),
                    receiveConfiguration.PushRuntimeSettings.MaxConcurrency,
                    Satellites = receiveConfiguration.SatelliteDefinitions.Select(s => new
                    {
                        s.Name,
                        s.ReceiveAddress,
                        TransactionMode = s.RequiredTransportTransactionMode.ToString("G"),
                        s.RuntimeSettings.MaxConcurrency
                    }).ToArray()
                });
            }

            return(receiveComponent);
        }
예제 #3
0
        ReceiveComponent CreateReceiveComponent(ReceiveConfiguration receiveConfiguration,
                                                TransportInfrastructure transportInfrastructure,
                                                QueueBindings queueBindings,
                                                IPipelineCache pipelineCache,
                                                EventAggregator eventAggregator,
                                                IMessageMapper messageMapper)
        {
            var errorQueue = settings.ErrorQueueAddress();

            var receiveComponent = new ReceiveComponent(receiveConfiguration,
                                                        receiveConfiguration != null ? transportInfrastructure.ConfigureReceiveInfrastructure() : null, //don't create the receive infrastructure for send-only endpoints
                                                        pipelineCache,
                                                        pipelineConfiguration,
                                                        eventAggregator,
                                                        builder,
                                                        criticalError,
                                                        errorQueue,
                                                        messageMapper);

            receiveComponent.BindQueues(queueBindings);

            if (receiveConfiguration != null)
            {
                settings.AddStartupDiagnosticsSection("Receiving", new
                {
                    receiveConfiguration.LocalAddress,
                    receiveConfiguration.InstanceSpecificQueue,
                    receiveConfiguration.LogicalAddress,
                    receiveConfiguration.PurgeOnStartup,
                    receiveConfiguration.QueueNameBase,
                    TransactionMode = receiveConfiguration.TransactionMode.ToString("G"),
                    receiveConfiguration.PushRuntimeSettings.MaxConcurrency,
                    Satellites = receiveConfiguration.SatelliteDefinitions.Select(s => new
                    {
                        s.Name,
                        s.ReceiveAddress,
                        TransactionMode = s.RequiredTransportTransactionMode.ToString("G"),
                        s.RuntimeSettings.MaxConcurrency
                    }).ToArray()
                });
            }

            return(receiveComponent);
        }
예제 #4
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;
 }
예제 #5
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;
 }
예제 #6
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;
 }
예제 #7
0
        /// <summary>
        /// Loads all message handler assemblies in the runtime directory
        /// and specifies that the handlers in the given 'order' are to
        /// run before all others and in the order specified.
        /// </summary>
        /// <param name="config">The <see cref="EndpointConfiguration" /> instance to apply the settings to.</param>
        /// <param name="handlerTypes">The handler types to execute first.</param>
        public static void ExecuteTheseHandlersFirst(this EndpointConfiguration config, IEnumerable<Type> handlerTypes)
        {
            Guard.AgainstNull(nameof(config), config);
            Guard.AgainstNull(nameof(handlerTypes), handlerTypes);

            var list = config.Settings.Get<ReceiveComponent.Configuration>().ExecuteTheseHandlersFirst;

            foreach (var handlerType in handlerTypes)
            {
                if (!ReceiveComponent.IsMessageHandler(handlerType))
                {
                    throw new ArgumentException($"'{handlerType}' is not a handler type, ensure that all types derive from IHandleMessages");
                }

                if (list.Contains(handlerType))
                {
                    throw new ArgumentException($"The order in which the type '{handlerType}' should be invoked was already specified by a previous call. A handler type can only specified once.");
                }

                list.Add(handlerType);
            }
        }
예제 #8
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
            }
                                                  );
        }
 public RunningEndpointInstance(SettingsHolder settings, HostingComponent hostingComponent, ReceiveComponent receiveComponent, FeatureComponent featureComponent, IMessageSession messageSession, TransportInfrastructure transportInfrastructure, CancellationTokenSource stoppingTokenSource)
 {
     this.settings                = settings;
     this.hostingComponent        = hostingComponent;
     this.receiveComponent        = receiveComponent;
     this.featureComponent        = featureComponent;
     this.messageSession          = messageSession;
     this.transportInfrastructure = transportInfrastructure;
     this.stoppingTokenSource     = stoppingTokenSource;
 }
예제 #10
0
 public StartableEndpoint(SettingsHolder settings, IBuilder builder, FeatureActivator featureActivator, TransportInfrastructure transportInfrastructure, ReceiveComponent receiveComponent, CriticalError criticalError, IMessageSession messageSession)
 {
     this.criticalError           = criticalError;
     this.settings                = settings;
     this.builder                 = builder;
     this.featureActivator        = featureActivator;
     this.transportInfrastructure = transportInfrastructure;
     this.receiveComponent        = receiveComponent;
     this.messageSession          = messageSession;
 }
        public static ReceiveComponent Initialize(
            Configuration configuration,
            string errorQueue,
            HostingComponent.Configuration hostingConfiguration,
            PipelineSettings pipelineSettings)
        {
            TransportReceiveInfrastructure transportReceiveInfrastructure = null;

            if (!configuration.IsSendOnlyEndpoint)
            {
                transportReceiveInfrastructure = configuration.transportSeam.TransportInfrastructure.ConfigureReceiveInfrastructure();

                if (configuration.CreateQueues)
                {
                    hostingConfiguration.AddInstaller(identity =>
                    {
                        var queueCreator = transportReceiveInfrastructure.QueueCreatorFactory();
                        return(queueCreator.CreateQueueIfNecessary(configuration.transportSeam.QueueBindings, identity));
                    });
                }
            }

            var receiveComponent = new ReceiveComponent(
                configuration,
                hostingConfiguration.CriticalError,
                errorQueue,
                transportReceiveInfrastructure);

            if (configuration.IsSendOnlyEndpoint)
            {
                return(receiveComponent);
            }

            receiveComponent.BindQueues(configuration.transportSeam.QueueBindings);

            pipelineSettings.Register("TransportReceiveToPhysicalMessageProcessingConnector", b =>
            {
                var storage = hostingConfiguration.Container.HasComponent <IOutboxStorage>() ? b.Build <IOutboxStorage>() : new NoOpOutboxStorage();
                return(new TransportReceiveToPhysicalMessageConnector(storage));
            }, "Allows to abort processing the message");

            pipelineSettings.Register("LoadHandlersConnector", b =>
            {
                var adapter     = hostingConfiguration.Container.HasComponent <ISynchronizedStorageAdapter>() ? b.Build <ISynchronizedStorageAdapter>() : new NoOpSynchronizedStorageAdapter();
                var syncStorage = hostingConfiguration.Container.HasComponent <ISynchronizedStorage>() ? b.Build <ISynchronizedStorage>() : new NoOpSynchronizedStorage();

                return(new LoadHandlersConnector(b.Build <MessageHandlerRegistry>(), syncStorage, adapter));
            }, "Gets all the handlers to invoke from the MessageHandler registry based on the message type.");

            pipelineSettings.Register("ExecuteUnitOfWork", new UnitOfWorkBehavior(), "Executes the UoW");

            pipelineSettings.Register("InvokeHandlers", new InvokeHandlerTerminator(), "Calls the IHandleMessages<T>.Handle(T)");

            var externalHandlerRegistryUsed = hostingConfiguration.Container.HasComponent <MessageHandlerRegistry>();
            var handlerDiagnostics          = new Dictionary <string, List <string> >();

            if (!externalHandlerRegistryUsed)
            {
                var messageHandlerRegistry = configuration.messageHandlerRegistry;

                RegisterMessageHandlers(messageHandlerRegistry, configuration.ExecuteTheseHandlersFirst, hostingConfiguration.Container, hostingConfiguration.AvailableTypes);

                foreach (var messageType in messageHandlerRegistry.GetMessageTypes())
                {
                    handlerDiagnostics[messageType.FullName] = messageHandlerRegistry.GetHandlersFor(messageType)
                                                               .Select(handler => handler.HandlerType.FullName)
                                                               .ToList();
                }
            }

            hostingConfiguration.AddStartupDiagnosticsSection("Receiving", new
            {
                configuration.LocalAddress,
                configuration.InstanceSpecificQueue,
                configuration.LogicalAddress,
                configuration.PurgeOnStartup,
                configuration.QueueNameBase,
                TransactionMode = configuration.TransactionMode.ToString("G"),
                configuration.PushRuntimeSettings.MaxConcurrency,
                Satellites = configuration.SatelliteDefinitions.Select(s => new
                {
                    s.Name,
                    s.ReceiveAddress,
                    TransactionMode = s.RequiredTransportTransactionMode.ToString("G"),
                    s.RuntimeSettings.MaxConcurrency
                }).ToArray(),
                ExternalHandlerRegistry = externalHandlerRegistryUsed,
                MessageHandlers         = handlerDiagnostics
            });

            return(receiveComponent);
        }
예제 #12
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);

            transportComponent = TransportComponent.Initialize(settings.Get <TransportComponent.Configuration>(), settings);

            var receiveConfiguration = BuildReceiveConfiguration(transportComponent);

            var routingComponent = new RoutingComponent(settings);

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

            routingComponent.Initialize(transportComponent, pipelineSettings, receiveConfiguration);

            var messageMapper = new MessageMapper();

            settings.Set <IMessageMapper>(messageMapper);

            recoverabilityComponent = new RecoverabilityComponent(settings);

            var featureConfigurationContext = new FeatureConfigurationContext(settings, containerComponent.ContainerConfiguration, 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();

            hostingComponent = HostingComponent.Initialize(settings.Get <HostingComponent.Configuration>(), containerComponent, pipelineSettings);

            recoverabilityComponent.Initialize(receiveConfiguration, hostingComponent);

            pipelineComponent = PipelineComponent.Initialize(pipelineSettings, containerComponent);
            pipelineComponent.AddRootContextItem <IMessageMapper>(messageMapper);

            containerComponent.ContainerConfiguration.ConfigureComponent(b => settings.Get <Notifications>(), DependencyLifecycle.SingleInstance);
            var eventAggregator = new EventAggregator(settings.Get <NotificationSubscriptions>());

            pipelineComponent.AddRootContextItem <IEventAggregator>(eventAggregator);

            receiveComponent = ReceiveComponent.Initialize(receiveConfiguration,
                                                           transportComponent,
                                                           pipelineComponent,
                                                           eventAggregator,
                                                           criticalError,
                                                           settings.ErrorQueueAddress(),
                                                           hostingComponent);

            installationComponent = InstallationComponent.Initialize(settings.Get <InstallationComponent.Configuration>(),
                                                                     concreteTypes,
                                                                     containerComponent,
                                                                     transportComponent);

            settings.AddStartupDiagnosticsSection("Endpoint",
                                                  new
            {
                Name               = settings.EndpointName(),
                SendOnly           = settings.Get <bool>("Endpoint.SendOnly"),
                NServiceBusVersion = GitVersionInformation.MajorMinorPatch
            }
                                                  );
        }
예제 #13
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
            }
                                                  );
        }
예제 #14
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;
 }
예제 #15
0
        public static ReceiveComponent Configure(
            Configuration configuration,
            string errorQueue,
            HostingComponent.Configuration hostingConfiguration,
            PipelineSettings pipelineSettings)
        {
            if (configuration.IsSendOnlyEndpoint)
            {
                configuration.transportSeam.Configure(new ReceiveSettings[0]);
                return(new ReceiveComponent(configuration));
            }

            var receiveComponent = new ReceiveComponent(configuration);

            pipelineSettings.Register("TransportReceiveToPhysicalMessageProcessingConnector", b =>
            {
                var storage = b.GetService <IOutboxStorage>() ?? new NoOpOutboxStorage();
                return(new TransportReceiveToPhysicalMessageConnector(storage));
            }, "Allows to abort processing the message");

            pipelineSettings.Register("LoadHandlersConnector", b =>
            {
                var adapter     = b.GetService <ISynchronizedStorageAdapter>() ?? new NoOpSynchronizedStorageAdapter();
                var syncStorage = b.GetService <ISynchronizedStorage>() ?? new NoOpSynchronizedStorage();

                return(new LoadHandlersConnector(b.GetRequiredService <MessageHandlerRegistry>(), syncStorage, adapter));
            }, "Gets all the handlers to invoke from the MessageHandler registry based on the message type.");

            pipelineSettings.Register("ExecuteUnitOfWork", new UnitOfWorkBehavior(), "Executes the UoW");

            pipelineSettings.Register("InvokeHandlers", new InvokeHandlerTerminator(), "Calls the IHandleMessages<T>.Handle(T)");

            var handlerDiagnostics = new Dictionary <string, List <string> >();


            var messageHandlerRegistry = configuration.messageHandlerRegistry;

            RegisterMessageHandlers(messageHandlerRegistry, configuration.ExecuteTheseHandlersFirst, hostingConfiguration.Services, hostingConfiguration.AvailableTypes);

            foreach (var messageType in messageHandlerRegistry.GetMessageTypes())
            {
                handlerDiagnostics[messageType.FullName] = messageHandlerRegistry.GetHandlersFor(messageType)
                                                           .Select(handler => handler.HandlerType.FullName)
                                                           .ToList();
            }

            var receiveSettings = new List <ReceiveSettings>
            {
                new ReceiveSettings(
                    MainReceiverId,
                    configuration.LocalAddress,
                    configuration.transportSeam.TransportDefinition.SupportsPublishSubscribe,
                    configuration.PurgeOnStartup,
                    errorQueue)
            };


            if (!string.IsNullOrWhiteSpace(configuration.InstanceSpecificQueue))
            {
                receiveSettings.Add(new ReceiveSettings(
                                        InstanceSpecificReceiverId,
                                        configuration.InstanceSpecificQueue,
                                        false,
                                        configuration.PurgeOnStartup,
                                        errorQueue));
            }

            receiveSettings.AddRange(configuration.SatelliteDefinitions.Select(definition => new ReceiveSettings(
                                                                                   definition.Name,
                                                                                   definition.ReceiveAddress,
                                                                                   false,
                                                                                   configuration.PurgeOnStartup,
                                                                                   errorQueue)));

            hostingConfiguration.Services.ConfigureComponent(() => receiveComponent.mainReceiverSubscriptionManager, DependencyLifecycle.SingleInstance);
            // get a reference to the subscription manager as soon as the transport has been created:
            configuration.transportSeam.TransportInfrastructureCreated += (_, infrastructure) =>
                                                                          receiveComponent.mainReceiverSubscriptionManager =
                infrastructure.Receivers[MainReceiverId].Subscriptions;

            configuration.transportSeam.Configure(receiveSettings.ToArray());

            hostingConfiguration.AddStartupDiagnosticsSection("Receiving", new
            {
                configuration.LocalAddress,
                configuration.InstanceSpecificQueue,
                configuration.PurgeOnStartup,
                configuration.QueueNameBase,
                TransactionMode = configuration.transportSeam.TransportDefinition.TransportTransactionMode.ToString("G"),
                configuration.PushRuntimeSettings.MaxConcurrency,
                Satellites = configuration.SatelliteDefinitions.Select(s => new
                {
                    s.Name,
                    s.ReceiveAddress,
                    s.RuntimeSettings.MaxConcurrency
                }).ToArray(),
                MessageHandlers = handlerDiagnostics
            });

            return(receiveComponent);
        }
예제 #16
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;
 }
예제 #17
0
        public static ReceiveComponent Initialize(Configuration configuration,
                                                  ReceiveConfiguration transportReceiveConfiguration,
                                                  TransportComponent.Configuration transportConfiguration,
                                                  PipelineComponent pipelineComponent,
                                                  string errorQueue,
                                                  HostingComponent.Configuration hostingConfiguration,
                                                  PipelineSettings pipelineSettings)

        {
            var receiveComponent = new ReceiveComponent(transportReceiveConfiguration,
                                                        pipelineComponent,
                                                        hostingConfiguration.CriticalError,
                                                        errorQueue);

            receiveComponent.BindQueues(transportConfiguration.QueueBindings);

            pipelineSettings.Register("TransportReceiveToPhysicalMessageProcessingConnector", b =>
            {
                var storage = hostingConfiguration.Container.HasComponent <IOutboxStorage>() ? b.Build <IOutboxStorage>() : new NoOpOutboxStorage();
                return(new TransportReceiveToPhysicalMessageConnector(storage));
            }, "Allows to abort processing the message");

            pipelineSettings.Register("LoadHandlersConnector", b =>
            {
                var adapter     = hostingConfiguration.Container.HasComponent <ISynchronizedStorageAdapter>() ? b.Build <ISynchronizedStorageAdapter>() : new NoOpSynchronizedStorageAdapter();
                var syncStorage = hostingConfiguration.Container.HasComponent <ISynchronizedStorage>() ? b.Build <ISynchronizedStorage>() : new NoOpSynchronizedStorage();

                return(new LoadHandlersConnector(b.Build <MessageHandlerRegistry>(), syncStorage, adapter));
            }, "Gets all the handlers to invoke from the MessageHandler registry based on the message type.");

            pipelineSettings.Register("ExecuteUnitOfWork", new UnitOfWorkBehavior(), "Executes the UoW");

            pipelineSettings.Register("InvokeHandlers", new InvokeHandlerTerminator(), "Calls the IHandleMessages<T>.Handle(T)");

            if (!hostingConfiguration.Container.HasComponent <MessageHandlerRegistry>())
            {
                var orderedHandlers = configuration.ExecuteTheseHandlersFirst;

                LoadMessageHandlers(configuration, orderedHandlers, hostingConfiguration.Container, hostingConfiguration.AvailableTypes);
            }

            if (transportReceiveConfiguration != null)
            {
                hostingConfiguration.AddStartupDiagnosticsSection("Receiving", new
                {
                    transportReceiveConfiguration.LocalAddress,
                    transportReceiveConfiguration.InstanceSpecificQueue,
                    transportReceiveConfiguration.LogicalAddress,
                    transportReceiveConfiguration.PurgeOnStartup,
                    transportReceiveConfiguration.QueueNameBase,
                    TransactionMode = transportReceiveConfiguration.TransactionMode.ToString("G"),
                    transportReceiveConfiguration.PushRuntimeSettings.MaxConcurrency,
                    Satellites = transportReceiveConfiguration.SatelliteDefinitions.Select(s => new
                    {
                        s.Name,
                        s.ReceiveAddress,
                        TransactionMode = s.RequiredTransportTransactionMode.ToString("G"),
                        s.RuntimeSettings.MaxConcurrency
                    }).ToArray()
                });
            }

            return(receiveComponent);
        }