public async Task PrepareToStart(ContainerComponent containerComponent, RecoverabilityComponent recoverabilityComponent) { if (IsSendOnly) { return; } mainPipelineExecutor = new MainPipelineExecutor(containerComponent.Builder, pipeline); if (configuration.PurgeOnStartup) { Logger.Warn("All queues owned by the endpoint will be purged on startup."); } AddReceivers(containerComponent.Builder, recoverabilityComponent.GetRecoverabilityExecutorFactory(containerComponent.Builder)); foreach (var receiver in receivers) { try { await receiver.Init().ConfigureAwait(false); } catch (Exception ex) { Logger.Fatal($"Receiver {receiver.Id} failed to initialize.", ex); throw; } } }
public async Task Initialize() { if (IsSendOnly) { return; } var mainPipeline = new Pipeline <ITransportReceiveContext>(builder, pipelineConfiguration.Modifications); mainPipelineExecutor = new MainPipelineExecutor(builder, eventAggregator, pipelineCache, mainPipeline, messageMapper); if (configuration.PurgeOnStartup) { Logger.Warn("All queues owned by the endpoint will be purged on startup."); } AddReceivers(); foreach (var receiver in receivers) { try { await receiver.Init().ConfigureAwait(false); } catch (Exception ex) { Logger.Fatal($"Receiver {receiver.Id} failed to initialize.", ex); throw; } } }
public async Task PrepareToStart(IBuilder builder, RecoverabilityComponent recoverabilityComponent, MessageOperations messageOperations, PipelineComponent pipelineComponent, IPipelineCache pipelineCache) { if (configuration.IsSendOnlyEndpoint) { return; } var receivePipeline = pipelineComponent.CreatePipeline <ITransportReceiveContext>(builder); mainPipelineExecutor = new MainPipelineExecutor(builder, pipelineCache, messageOperations, configuration.PipelineCompletedSubscribers, receivePipeline); if (configuration.PurgeOnStartup) { Logger.Warn("All queues owned by the endpoint will be purged on startup."); } AddReceivers(builder, recoverabilityComponent.GetRecoverabilityExecutorFactory(builder), transportReceiveInfrastructure.MessagePumpFactory); foreach (var receiver in receivers) { try { await receiver.Init().ConfigureAwait(false); } catch (Exception ex) { Logger.Fatal($"Receiver {receiver.Id} failed to initialize.", ex); throw; } } }
List <TransportReceiver> BuildMainReceivers(string errorQueue, bool purgeOnStartup, TransportTransactionMode requiredTransactionSupport, RecoverabilityExecutorFactory recoverabilityExecutorFactory, IPipeline <ITransportReceiveContext> mainPipeline) { var localAddress = settings.LocalAddress(); var distributorAddress = settings.GetOrDefault <string>("LegacyDistributor.Address"); var recoverabilityExecutor = recoverabilityExecutorFactory.CreateDefault(eventAggregator, distributorAddress ?? localAddress); var pushSettings = new PushSettings(settings.LocalAddress(), errorQueue, purgeOnStartup, requiredTransactionSupport); var mainPipelineExecutor = new MainPipelineExecutor(builder, eventAggregator, pipelineCache, mainPipeline); var dequeueLimitations = GetDequeueLimitationsForReceivePipeline(); var receivers = new List <TransportReceiver>(); receivers.Add(new TransportReceiver(MainReceiverId, builder.Build <IPushMessages>(), pushSettings, dequeueLimitations, mainPipelineExecutor, recoverabilityExecutor, criticalError)); if (settings.InstanceSpecificQueue() != null) { var instanceSpecificQueue = settings.InstanceSpecificQueue(); var instanceSpecificRecoverabilityExecutor = recoverabilityExecutorFactory.CreateDefault(eventAggregator, instanceSpecificQueue); var sharedReceiverPushSettings = new PushSettings(settings.InstanceSpecificQueue(), errorQueue, purgeOnStartup, requiredTransactionSupport); receivers.Add(new TransportReceiver(MainReceiverId, builder.Build <IPushMessages>(), sharedReceiverPushSettings, dequeueLimitations, mainPipelineExecutor, instanceSpecificRecoverabilityExecutor, criticalError)); } return(receivers); }
public async Task Initialize() { if (IsSendOnly) { return; } mainPipelineExecutor = new MainPipelineExecutor(builder, pipeline); if (configuration.PurgeOnStartup) { Logger.Warn("All queues owned by the endpoint will be purged on startup."); } AddReceivers(); foreach (var receiver in receivers) { try { await receiver.Init().ConfigureAwait(false); } catch (Exception ex) { Logger.Fatal($"Receiver {receiver.Id} failed to initialize.", ex); throw; } } }
public async Task Initialize(IServiceProvider builder, RecoverabilityComponent recoverabilityComponent, MessageOperations messageOperations, PipelineComponent pipelineComponent, IPipelineCache pipelineCache, TransportInfrastructure transportInfrastructure, CancellationToken cancellationToken = default) { if (configuration.IsSendOnlyEndpoint) { return; } var mainPump = transportInfrastructure.Receivers[MainReceiverId]; var receivePipeline = pipelineComponent.CreatePipeline <ITransportReceiveContext>(builder); var mainPipelineExecutor = new MainPipelineExecutor(builder, pipelineCache, messageOperations, configuration.PipelineCompletedSubscribers, receivePipeline); var recoverabilityExecutorFactory = recoverabilityComponent.GetRecoverabilityExecutorFactory(builder); var recoverability = recoverabilityExecutorFactory .CreateDefault(configuration.LocalAddress); await mainPump.Initialize(configuration.PushRuntimeSettings, mainPipelineExecutor.Invoke, recoverability.Invoke, cancellationToken).ConfigureAwait(false); receivers.Add(mainPump); if (transportInfrastructure.Receivers.TryGetValue(InstanceSpecificReceiverId, out var instanceSpecificPump)) { var instanceSpecificRecoverabilityExecutor = recoverabilityExecutorFactory.CreateDefault(configuration.InstanceSpecificQueue); await instanceSpecificPump.Initialize(configuration.PushRuntimeSettings, mainPipelineExecutor.Invoke, instanceSpecificRecoverabilityExecutor.Invoke, cancellationToken).ConfigureAwait(false); receivers.Add(instanceSpecificPump); } foreach (var satellite in configuration.SatelliteDefinitions) { try { var satellitePump = transportInfrastructure.Receivers[satellite.Name]; var satellitePipeline = new SatellitePipelineExecutor(builder, satellite); var satelliteRecoverabilityExecutor = recoverabilityExecutorFactory.Create(satellite.RecoverabilityPolicy, satellite.ReceiveAddress); await satellitePump.Initialize(satellite.RuntimeSettings, satellitePipeline.Invoke, satelliteRecoverabilityExecutor.Invoke, cancellationToken).ConfigureAwait(false); receivers.Add(satellitePump); } catch (Exception ex) when(!ex.IsCausedBy(cancellationToken)) { Logger.Fatal("Satellite failed to start.", ex); throw; } } }
ReceiveComponent CreateReceiveComponent(ReceiveConfiguration receiveConfiguration, TransportInfrastructure transportInfrastructure, QueueBindings queueBindings, IPipelineCache pipelineCache, EventAggregator eventAggregator) { var mainPipeline = new Pipeline <ITransportReceiveContext>(builder, pipelineConfiguration.Modifications); var mainPipelineExecutor = new MainPipelineExecutor(builder, eventAggregator, pipelineCache, mainPipeline); var errorQueue = settings.ErrorQueueAddress(); var receiveComponent = new ReceiveComponent(receiveConfiguration, receiveConfiguration != null ? transportInfrastructure.ConfigureReceiveInfrastructure() : null, //don't create the receive infrastructure for send-only endpoints mainPipelineExecutor, eventAggregator, builder, criticalError, errorQueue); 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); }
public async Task Initialize() { if (IsSendOnly) { return; } mainPipelineExecutor = new MainPipelineExecutor(builder, pipeline); var recoverabilityExecutorFactory = builder.Build <RecoverabilityExecutorFactory>(); mainRecoverabilityExecutor = recoverabilityExecutorFactory.CreateDefault(eventAggregator, configuration.LocalAddress); if (UseManualPump) { return; } if (configuration.PurgeOnStartup) { Logger.Warn("All queues owned by the endpoint will be purged on startup."); } AddReceivers(recoverabilityExecutorFactory); foreach (var receiver in receivers) { try { await receiver.Init().ConfigureAwait(false); } catch (Exception ex) { Logger.Fatal($"Receiver {receiver.Id} failed to initialize.", ex); throw; } } }
List<TransportReceiver> BuildMainReceivers(string errorQueue, bool purgeOnStartup, TransportTransactionMode requiredTransactionSupport, RecoverabilityExecutorFactory recoverabilityExecutorFactory, IPipeline<ITransportReceiveContext> mainPipeline) { var localAddress = settings.LocalAddress(); var distributorAddress = settings.GetOrDefault<string>("LegacyDistributor.Address"); var recoverabilityExecutor = recoverabilityExecutorFactory.CreateDefault(eventAggregator, distributorAddress ?? localAddress); var pushSettings = new PushSettings(settings.LocalAddress(), errorQueue, purgeOnStartup, requiredTransactionSupport); var mainPipelineExecutor = new MainPipelineExecutor(builder, eventAggregator, pipelineCache, mainPipeline); var dequeueLimitations = GetDequeueLimitationsForReceivePipeline(); var receivers = new List<TransportReceiver>(); receivers.Add(new TransportReceiver(MainReceiverId, builder.Build<IPushMessages>(), pushSettings, dequeueLimitations, mainPipelineExecutor, recoverabilityExecutor, criticalError)); if (settings.InstanceSpecificQueue() != null) { var instanceSpecificQueue = settings.InstanceSpecificQueue(); var instanceSpecificRecoverabilityExecutor = recoverabilityExecutorFactory.CreateDefault(eventAggregator, instanceSpecificQueue); var sharedReceiverPushSettings = new PushSettings(settings.InstanceSpecificQueue(), errorQueue, purgeOnStartup, requiredTransactionSupport); receivers.Add(new TransportReceiver(MainReceiverId, builder.Build<IPushMessages>(), sharedReceiverPushSettings, dequeueLimitations, mainPipelineExecutor, instanceSpecificRecoverabilityExecutor, criticalError)); } return receivers; }