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; } } }
public void Initialize(TransportComponent transportComponent, PipelineSettings pipelineSettings, 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); pipelineSettings.Register("UnicastSendRouterConnector", b => { var router = new UnicastSendRouter(receiveConfiguration == null, receiveConfiguration?.QueueNameBase, receiveConfiguration?.InstanceSpecificQueue, DistributionPolicy, UnicastRoutingTable, EndpointInstances, i => transportComponent.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i))); return(new SendConnector(router)); }, "Determines how the message being sent should be routed"); pipelineSettings.Register("UnicastReplyRouterConnector", new ReplyConnector(), "Determines how replies should be routed"); EnforceBestPractices = ShouldEnforceBestPractices(settings); if (EnforceBestPractices) { EnableBestPracticeEnforcement(conventions, pipelineSettings); } }
ReceiveConfiguration BuildReceiveConfiguration(TransportComponent transportComponent) { var receiveConfiguration = ReceiveConfigurationBuilder.Build(settings, transportComponent); if (receiveConfiguration == null) { return(null); } //note: remove once settings.LogicalAddress() , .LocalAddress() and .InstanceSpecificQueue() has been obsoleted settings.Set(receiveConfiguration); return(receiveConfiguration); }
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 Start(IBuilder builder, TransportComponent transportComponent) { if (!configuration.ShouldRunInstallers) { return; } var installationUserName = GetInstallationUserName(); if (configuration.ShouldCreateQueues) { await transportComponent.CreateQueuesIfNecessary(installationUserName).ConfigureAwait(false); } foreach (var installer in builder.BuildAll <INeedToInstallSomething>()) { await installer.Install(installationUserName).ConfigureAwait(false); } }
public static TransportComponent Initialize(Configuration configuration, HostingComponent.Configuration hostingConfiguration) { var transportComponent = new TransportComponent(configuration.transportInfrastructure, configuration.QueueBindings); if (configuration.ReceivingEnabled) { transportComponent.ConfigureReceiveInfrastructure(); } hostingConfiguration.Container.ConfigureComponent(() => transportComponent.GetOrCreateDispatcher(), DependencyLifecycle.SingleInstance); hostingConfiguration.AddStartupDiagnosticsSection("Transport", new { Type = configuration.TransportType.FullName, Version = FileVersionRetriever.GetFileVersion(configuration.TransportType) }); return(transportComponent); }
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; }
public StartableEndpoint(SettingsHolder settings, FeatureComponent featureComponent, TransportComponent transportComponent, ReceiveComponent receiveComponent, PipelineComponent pipelineComponent, RecoverabilityComponent recoverabilityComponent, HostingComponent hostingComponent, SendComponent sendComponent, IBuilder builder) { this.settings = settings; this.featureComponent = featureComponent; this.transportComponent = transportComponent; this.receiveComponent = receiveComponent; this.pipelineComponent = pipelineComponent; this.recoverabilityComponent = recoverabilityComponent; this.hostingComponent = hostingComponent; this.sendComponent = sendComponent; this.builder = builder; }
public static ReceiveConfiguration Build(ReadOnlySettings settings, TransportComponent transportComponent) { var isSendOnlyEndpoint = settings.Get <bool>("Endpoint.SendOnly"); if (isSendOnlyEndpoint) { if (settings.HasExplicitValue(ReceiveSettingsExtensions.CustomLocalAddressKey)) { throw new Exception($"Specifying a base name for the input queue using `{nameof(ReceiveSettingsExtensions.OverrideLocalAddress)}(baseInputQueueName)` is not supported for send-only endpoints."); } return(null); } var endpointName = settings.EndpointName(); var discriminator = settings.GetOrDefault <string>("EndpointInstanceDiscriminator"); var queueNameBase = settings.GetOrDefault <string>(ReceiveSettingsExtensions.CustomLocalAddressKey) ?? endpointName; var purgeOnStartup = settings.GetOrDefault <bool>("Transport.PurgeOnStartup"); //note: This is an old hack, we are passing the endpoint name to bind but we only care about the properties var mainInstanceProperties = transportComponent.BindToLocalEndpoint(new EndpointInstance(endpointName)).Properties; var logicalAddress = LogicalAddress.CreateLocalAddress(queueNameBase, mainInstanceProperties); var localAddress = transportComponent.ToTransportAddress(logicalAddress); string instanceSpecificQueue = null; if (discriminator != null) { instanceSpecificQueue = transportComponent.ToTransportAddress(logicalAddress.CreateIndividualizedAddress(discriminator)); } var transactionMode = GetRequiredTransactionMode(settings); var pushRuntimeSettings = GetDequeueLimitations(settings); return(new ReceiveConfiguration(logicalAddress, queueNameBase, localAddress, instanceSpecificQueue, transactionMode, pushRuntimeSettings, purgeOnStartup)); }
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, 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; }
public static InstallationComponent Initialize(Configuration configuration, List <Type> concreteTypes, ContainerComponent containerComponent, TransportComponent transportComponent) { var component = new InstallationComponent(configuration, containerComponent, transportComponent); if (!configuration.ShouldRunInstallers) { return(component); } foreach (var installerType in concreteTypes.Where(t => IsINeedToInstallSomething(t))) { containerComponent.ContainerConfiguration.ConfigureComponent(installerType, DependencyLifecycle.InstancePerCall); } return(component); }
InstallationComponent(Configuration configuration, ContainerComponent containerComponent, TransportComponent transportComponent) { this.configuration = configuration; this.containerComponent = containerComponent; this.transportComponent = transportComponent; }
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 } ); }