ReceiveComponent(Configuration configuration,
                  CriticalError criticalError,
                  string errorQueue,
                  TransportReceiveInfrastructure transportReceiveInfrastructure)
 {
     this.configuration = configuration;
     this.criticalError = criticalError;
     this.errorQueue    = errorQueue;
     this.transportReceiveInfrastructure = transportReceiveInfrastructure;
 }
Ejemplo n.º 2
0
 public ReceiveComponent(ReceiveConfiguration configuration,
                         TransportReceiveInfrastructure receiveInfrastructure,
                         PipelineComponent pipeline,
                         IEventAggregator eventAggregator,
                         CriticalError criticalError,
                         string errorQueue)
 {
     this.configuration         = configuration;
     this.receiveInfrastructure = receiveInfrastructure;
     this.pipeline        = pipeline;
     this.eventAggregator = eventAggregator;
     this.criticalError   = criticalError;
     this.errorQueue      = errorQueue;
 }
Ejemplo n.º 3
0
 public ReceiveComponent(ReceiveConfiguration configuration,
                         TransportReceiveInfrastructure receiveInfrastructure,
                         IPipelineExecutor mainPipelineExecutor,
                         IEventAggregator eventAggregator,
                         IBuilder builder,
                         CriticalError criticalError,
                         string errorQueue)
 {
     this.configuration         = configuration;
     this.receiveInfrastructure = receiveInfrastructure;
     this.mainPipelineExecutor  = mainPipelineExecutor;
     this.eventAggregator       = eventAggregator;
     this.builder       = builder;
     this.criticalError = criticalError;
     this.errorQueue    = errorQueue;
 }
Ejemplo n.º 4
0
 public ReceiveComponent(SettingsHolder settings,
                         ReceiveConfiguration configuration,
                         TransportReceiveInfrastructure receiveInfrastructure,
                         PipelineComponent pipeline,
                         IBuilder builder,
                         IEventAggregator eventAggregator,
                         CriticalError criticalError,
                         string errorQueue)
 {
     this.settings              = settings;
     this.configuration         = configuration;
     this.receiveInfrastructure = receiveInfrastructure;
     this.pipeline              = pipeline;
     this.builder         = builder;
     this.eventAggregator = eventAggregator;
     this.criticalError   = criticalError;
     this.errorQueue      = errorQueue;
 }
Ejemplo n.º 5
0
 public ReceiveComponent(ReceiveConfiguration configuration,
                         TransportReceiveInfrastructure receiveInfrastructure,
                         IPipelineCache pipelineCache,
                         PipelineConfiguration pipelineConfiguration,
                         IEventAggregator eventAggregator,
                         IBuilder builder,
                         CriticalError criticalError,
                         string errorQueue,
                         IMessageMapper messageMapper)
 {
     this.configuration         = configuration;
     this.receiveInfrastructure = receiveInfrastructure;
     this.pipelineCache         = pipelineCache;
     this.pipelineConfiguration = pipelineConfiguration;
     this.eventAggregator       = eventAggregator;
     this.builder       = builder;
     this.criticalError = criticalError;
     this.errorQueue    = errorQueue;
     this.messageMapper = messageMapper;
 }
        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);
        }