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); }
public async Task PrepareToStart(IBuilder builder, RecoverabilityComponent recoverabilityComponent, MessageOperations messageOperations, IPipelineCache pipelineCache, TransportComponent transportComponent) { if (IsSendOnly) { return; } var receivePipeline = pipelineComponent.CreatePipeline <ITransportReceiveContext>(builder); mainPipelineExecutor = new MainPipelineExecutor(builder, pipelineCache, messageOperations, transportReceiveConfiguration.PipelineCompletedSubscribers, receivePipeline); if (transportReceiveConfiguration.PurgeOnStartup) { Logger.Warn("All queues owned by the endpoint will be purged on startup."); } AddReceivers(builder, recoverabilityComponent.GetRecoverabilityExecutorFactory(builder), transportComponent.GetMessagePumpFactory()); foreach (var receiver in receivers) { try { await receiver.Init().ConfigureAwait(false); } catch (Exception ex) { Logger.Fatal($"Receiver {receiver.Id} failed to initialize.", ex); throw; } } }