Exemplo n.º 1
0
        public void Initialize(ReceiveConfiguration receiveConfiguration)
        {
            if (settings.GetOrDefault <bool>("Endpoint.SendOnly"))
            {
                //Message recoverability is only relevant for endpoints receiving messages.
                return;
            }

            transactionsOn = receiveConfiguration.TransactionMode != TransportTransactionMode.None;

            var errorQueue = settings.ErrorQueueAddress();

            settings.Get <QueueBindings>().BindSending(errorQueue);

            var delayedRetryConfig = GetDelayedRetryConfig();

            var immediateRetryConfig = GetImmediateRetryConfig();

            var failedConfig = new FailedConfig(errorQueue, settings.UnrecoverableExceptions());

            recoverabilityConfig = new RecoverabilityConfig(immediateRetryConfig, delayedRetryConfig, failedConfig);

            settings.AddStartupDiagnosticsSection("Recoverability", new
            {
                ImmediateRetries           = recoverabilityConfig.Immediate.MaxNumberOfRetries,
                DelayedRetries             = recoverabilityConfig.Delayed.MaxNumberOfRetries,
                DelayedRetriesTimeIncrease = recoverabilityConfig.Delayed.TimeIncrease.ToString("g"),
                recoverabilityConfig.Failed.ErrorQueue,
                UnrecoverableExceptions = recoverabilityConfig.Failed.UnrecoverableExceptionTypes.Select(t => t.FullName).ToArray()
            });

            WireUpLegacyNotifications();
        }
Exemplo n.º 2
0
 ReceiveComponent(ReceiveConfiguration transportReceiveConfiguration,
                  PipelineComponent pipelineComponent,
                  CriticalError criticalError,
                  string errorQueue)
 {
     this.transportReceiveConfiguration = transportReceiveConfiguration;
     this.pipelineComponent             = pipelineComponent;
     this.criticalError = criticalError;
     this.errorQueue    = errorQueue;
 }
Exemplo n.º 3
0
 ReceiveComponent(ReceiveConfiguration configuration,
                  Func <IPushMessages> messagePumpFactory,
                  PipelineComponent pipeline,
                  IEventAggregator eventAggregator,
                  CriticalError criticalError,
                  string errorQueue)
 {
     this.configuration      = configuration;
     this.messagePumpFactory = messagePumpFactory;
     this.pipeline           = pipeline;
     this.eventAggregator    = eventAggregator;
     this.criticalError      = criticalError;
     this.errorQueue         = errorQueue;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
        public static RoutingComponent Initialize(Configuration configuration,
                                                  TransportComponent.Configuration transportConfiguration,
                                                  ReceiveConfiguration receiveConfiguration,
                                                  Conventions conventions,
                                                  PipelineSettings pipelineSettings)
        {
            var distributionPolicy  = configuration.DistributionPolicy;
            var unicastRoutingTable = configuration.UnicastRoutingTable;
            var endpointInstances   = configuration.EndpointInstances;

            foreach (var distributionStrategy in configuration.DistributionStrategies)
            {
                distributionPolicy.SetDistributionStrategy(distributionStrategy);
            }

            configuration.ConfiguredUnicastRoutes?.Apply(unicastRoutingTable, conventions);

            var isSendOnlyEndpoint = receiveConfiguration == null;

            if (isSendOnlyEndpoint == false)
            {
                pipelineSettings.Register(new ApplyReplyToAddressBehavior(
                                              receiveConfiguration.LocalAddress,
                                              receiveConfiguration.InstanceSpecificQueue,
                                              configuration.PublicReturnAddress),
                                          "Applies the public reply to address to outgoing messages");
            }

            var sendRouter = new UnicastSendRouter(
                isSendOnlyEndpoint,
                receiveConfiguration?.QueueNameBase,
                receiveConfiguration?.InstanceSpecificQueue,
                distributionPolicy,
                unicastRoutingTable,
                endpointInstances,
                i => transportConfiguration.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));

            return(new RoutingComponent(
                       unicastRoutingTable,
                       distributionPolicy,
                       endpointInstances,
                       configuration.Publishers,
                       sendRouter,
                       configuration.EnforceBestPractices,
                       new Validations(conventions)));
        }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public void Initialize(TransportInfrastructure transportInfrastructure, PipelineComponent pipelineComponent, ReceiveConfiguration receiveConfiguration)
        {
            var conventions             = settings.Get <Conventions>();
            var configuredUnicastRoutes = settings.GetOrDefault <ConfiguredUnicastRoutes>();

            if (settings.TryGet(out List <DistributionStrategy> distributionStrategies))
            {
                foreach (var distributionStrategy in distributionStrategies)
                {
                    DistributionPolicy.SetDistributionStrategy(distributionStrategy);
                }
            }

            configuredUnicastRoutes?.Apply(UnicastRoutingTable, conventions);

            var pipelineSettings = pipelineComponent.PipelineSettings;

            pipelineSettings.Register(b =>
            {
                var router = new UnicastSendRouter(receiveConfiguration == null, receiveConfiguration?.QueueNameBase, receiveConfiguration?.InstanceSpecificQueue, DistributionPolicy, UnicastRoutingTable, EndpointInstances, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));
                return(new UnicastSendRouterConnector(router));
            }, "Determines how the message being sent should be routed");

            pipelineSettings.Register(new UnicastReplyRouterConnector(), "Determines how replies should be routed");

            EnforceBestPractices = ShouldEnforceBestPractices(settings);
            if (EnforceBestPractices)
            {
                EnableBestPracticeEnforcement(conventions, pipelineSettings);
            }
        }
Exemplo n.º 13
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);
        }