public Configuration(LogicalAddress logicalAddress, string queueNameBase, string localAddress, string instanceSpecificQueue, TransportTransactionMode transactionMode, PushRuntimeSettings pushRuntimeSettings, bool purgeOnStartup, Notification <ReceivePipelineCompleted> pipelineCompletedSubscribers, bool isSendOnlyEndpoint, List <Type> executeTheseHandlersFirst, MessageHandlerRegistry messageHandlerRegistry, bool createQueues, TransportSeam transportSeam) { LogicalAddress = logicalAddress; QueueNameBase = queueNameBase; LocalAddress = localAddress; InstanceSpecificQueue = instanceSpecificQueue; TransactionMode = transactionMode; PushRuntimeSettings = pushRuntimeSettings; PurgeOnStartup = purgeOnStartup; IsSendOnlyEndpoint = isSendOnlyEndpoint; PipelineCompletedSubscribers = pipelineCompletedSubscribers; ExecuteTheseHandlersFirst = executeTheseHandlersFirst; satelliteDefinitions = new List <SatelliteDefinition>(); this.messageHandlerRegistry = messageHandlerRegistry; CreateQueues = createQueues; this.transportSeam = transportSeam; }
public override string ToTransportAddress(LogicalAddress logicalAddress) { string machine; if (!logicalAddress.EndpointInstance.Properties.TryGetValue("machine", out machine)) { machine = RuntimeEnvironment.MachineName; } string queueName; if (!logicalAddress.EndpointInstance.Properties.TryGetValue("queue", out queueName)) { queueName = logicalAddress.EndpointInstance.Endpoint; } var queue = new StringBuilder(queueName); if (logicalAddress.EndpointInstance.Discriminator != null) { queue.Append("-" + logicalAddress.EndpointInstance.Discriminator); } if (logicalAddress.Qualifier != null) { queue.Append("." + logicalAddress.Qualifier); } return(queue + "@" + machine); }
internal Receiving() { EnableByDefault(); Prerequisite(c => !c.Settings.GetOrDefault <bool>("Endpoint.SendOnly"), "Endpoint is configured as send-only"); Defaults(s => { var transportInfrastructure = s.Get <TransportInfrastructure>(); var discriminator = s.GetOrDefault <string>("EndpointInstanceDiscriminator"); var baseQueueName = s.GetOrDefault <string>("BaseInputQueueName") ?? s.EndpointName(); var mainInstance = transportInfrastructure.BindToLocalEndpoint(new EndpointInstance(s.EndpointName())); var mainLogicalAddress = LogicalAddress.CreateLocalAddress(baseQueueName, mainInstance.Properties); s.SetDefault <LogicalAddress>(mainLogicalAddress); var mainAddress = transportInfrastructure.ToTransportAddress(mainLogicalAddress); s.SetDefault("NServiceBus.SharedQueue", mainAddress); if (discriminator != null) { var instanceSpecificAddress = transportInfrastructure.ToTransportAddress(mainLogicalAddress.CreateIndividualizedAddress(discriminator)); s.SetDefault("NServiceBus.EndpointSpecificQueue", instanceSpecificAddress); } }); }
public override string ToTransportAddress(LogicalAddress logicalAddress) { var address = logicalAddress.EndpointInstance.Endpoint; PathChecker.ThrowForBadPath(address, "endpoint name"); var discriminator = logicalAddress.EndpointInstance.Discriminator; if (!string.IsNullOrEmpty(discriminator)) { PathChecker.ThrowForBadPath(discriminator, "endpoint discriminator"); address += "-" + discriminator; } var qualifier = logicalAddress.Qualifier; if (!string.IsNullOrEmpty(qualifier)) { PathChecker.ThrowForBadPath(qualifier, "address qualifier"); address += "-" + qualifier; } return(address); }
public static Configuration PrepareConfiguration(Settings settings, TransportSeam transportSeam) { var isSendOnlyEndpoint = settings.IsSendOnlyEndpoint; if (isSendOnlyEndpoint && settings.CustomLocalAddressProvided) { throw new Exception($"Specifying a base name for the input queue using `{nameof(ReceiveSettingsExtensions.OverrideLocalAddress)}(baseInputQueueName)` is not supported for send-only endpoints."); } var endpointName = settings.EndpointName; var discriminator = settings.EndpointInstanceDiscriminator; var queueNameBase = settings.CustomLocalAddress ?? endpointName; var purgeOnStartup = settings.PurgeOnStartup; var transportInfrastructure = transportSeam.TransportInfrastructure; //note: This is an old hack, we are passing the endpoint name to bind but we only care about the properties var mainInstanceProperties = transportInfrastructure.BindToLocalEndpoint(new EndpointInstance(endpointName)).Properties; var logicalAddress = LogicalAddress.CreateLocalAddress(queueNameBase, mainInstanceProperties); var localAddress = transportInfrastructure.ToTransportAddress(logicalAddress); string instanceSpecificQueue = null; if (discriminator != null) { instanceSpecificQueue = transportInfrastructure.ToTransportAddress(logicalAddress.CreateIndividualizedAddress(discriminator)); } var transactionMode = GetRequiredTransactionMode(settings, transportInfrastructure); var pushRuntimeSettings = settings.PushRuntimeSettings; var receiveConfiguration = new Configuration( logicalAddress, queueNameBase, localAddress, instanceSpecificQueue, transactionMode, pushRuntimeSettings, purgeOnStartup, settings.PipelineCompletedSubscribers ?? new Notification <ReceivePipelineCompleted>(), isSendOnlyEndpoint, settings.ExecuteTheseHandlersFirst, settings.MessageHandlerRegistry, settings.ShouldCreateQueues, transportSeam); settings.RegisterReceiveConfigurationForBackwardsCompatibility(receiveConfiguration); return(receiveConfiguration); }
public override string ToTransportAddress(LogicalAddress logicalAddress) { var queue = new StringBuilder(logicalAddress.EndpointInstance.Endpoint); if (logicalAddress.EndpointInstance.Discriminator != null) { queue.Append("-" + logicalAddress.EndpointInstance.Discriminator); } if (logicalAddress.Qualifier != null) { queue.Append("_" + logicalAddress.Qualifier); } return(queue.ToString()); }
public static RoutingComponent Initialize( Configuration configuration, TransportSeam transportSeam, ReceiveComponent.Configuration receiveConfiguration, Conventions conventions, PipelineSettings pipelineSettings) { var distributionPolicy = configuration.DistributionPolicy; var unicastRoutingTable = configuration.UnicastRoutingTable; var endpointInstances = configuration.EndpointInstances; foreach (var distributionStrategy in configuration.CustomDistributionStrategies) { distributionPolicy.SetDistributionStrategy(distributionStrategy); } configuration.ConfiguredUnicastRoutes?.Apply(unicastRoutingTable, conventions); var isSendOnlyEndpoint = receiveConfiguration.IsSendOnlyEndpoint; if (!isSendOnlyEndpoint) { 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 => transportSeam.TransportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i))); if (configuration.EnforceBestPractices) { EnableBestPracticeEnforcement(pipelineSettings, new Validations(conventions)); } return(new RoutingComponent( sendRouter, configuration.EnforceBestPractices)); }
public override string ToTransportAddress(LogicalAddress logicalAddress) { var queueName = logicalAddress.EndpointInstance.Endpoint; var queue = new StringBuilder(queueName); if (logicalAddress.EndpointInstance.Discriminator != null) { queue.Append("-" + logicalAddress.EndpointInstance.Discriminator); } if (logicalAddress.Qualifier != null) { queue.Append("-" + logicalAddress.Qualifier); } return(QueueNameHelper.GetSanitizedQueueName(queue, queueName)); }
public static ReceiveConfiguration Build(ReadOnlySettings settings, TransportComponent.Configuration transportConfiguration) { 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 = transportConfiguration.BindToLocalEndpoint(new EndpointInstance(endpointName)).Properties; var logicalAddress = LogicalAddress.CreateLocalAddress(queueNameBase, mainInstanceProperties); var localAddress = transportConfiguration.ToTransportAddress(logicalAddress); string instanceSpecificQueue = null; if (discriminator != null) { instanceSpecificQueue = transportConfiguration.ToTransportAddress(logicalAddress.CreateIndividualizedAddress(discriminator)); } var transactionMode = GetRequiredTransactionMode(settings); var pushRuntimeSettings = GetDequeueLimitations(settings); return(new ReceiveConfiguration( logicalAddress, queueNameBase, localAddress, instanceSpecificQueue, transactionMode, pushRuntimeSettings, purgeOnStartup, settings.GetOrDefault <Notification <ReceivePipelineCompleted> >() ?? new Notification <ReceivePipelineCompleted>())); }
public ReceiveConfiguration(LogicalAddress logicalAddress, string queueNameBase, string localAddress, string instanceSpecificQueue, TransportTransactionMode transactionMode, PushRuntimeSettings pushRuntimeSettings, bool purgeOnStartup) { LogicalAddress = logicalAddress; QueueNameBase = queueNameBase; LocalAddress = localAddress; InstanceSpecificQueue = instanceSpecificQueue; TransactionMode = transactionMode; PushRuntimeSettings = pushRuntimeSettings; PurgeOnStartup = purgeOnStartup; satelliteDefinitions = new List <SatelliteDefinition>(); }
public override string ToTransportAddress(LogicalAddress logicalAddress) { string machine; if (!logicalAddress.EndpointInstance.Properties.TryGetValue("machine", out machine)) { machine = RuntimeEnvironment.MachineName; } string queueName; if (!logicalAddress.EndpointInstance.Properties.TryGetValue("queue", out queueName)) { queueName = logicalAddress.EndpointInstance.Endpoint; } var queue = new StringBuilder(queueName); if (logicalAddress.EndpointInstance.Discriminator != null) { queue.Append("-" + logicalAddress.EndpointInstance.Discriminator); } if (logicalAddress.Qualifier != null) { queue.Append("." + logicalAddress.Qualifier); } return queue + "@" + machine; }
bool Equals(LogicalAddress other) { return(string.Equals(Qualifier, other.Qualifier) && Equals(EndpointInstance, other.EndpointInstance)); }
public override string ToTransportAddress(LogicalAddress logicalAddress) { return Path.Combine(logicalAddress.EndpointInstance.Endpoint.ToString(), logicalAddress.EndpointInstance.Discriminator ?? "", logicalAddress.Qualifier ?? ""); }
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); } }
public string ToTransportAddress(LogicalAddress logicalAddress) { return(transportInfrastructure.ToTransportAddress(logicalAddress)); }
protected override void Setup(FeatureConfigurationContext context) { var transportInfrastructure = context.Settings.Get <TransportInfrastructure>(); var routingEngineConfig = context.Settings.Get <BlueprintAccessConfiguration>(); var routingEngine = routingEngineConfig.Create(); var outboundRoutingPolicy = context.Settings.Get <TransportInfrastructure>().OutboundRoutingPolicy; var evaluator = new BlueprintBasedRouteGenerator(context.Settings.EndpointName()); var router = new UnicastRouter(evaluator, context.Settings.Get <EndpointInstances>(), context.Settings.Get <DistributionPolicy>(), instance => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(instance))); context.RegisterStartupTask(new EngineManagementTask(routingEngine, map => evaluator.UpdateSourceData(map))); context.Pipeline.Register(new RouteToSitesBehavior(), "Adds site information to outgoing messages."); // if the transport provides native pub/sub support, don't plug in the FileBased pub/sub storage. if (outboundRoutingPolicy.Publishes == OutboundRoutingType.Unicast) { context.Pipeline.Replace("UnicastPublishRouterConnector", new PublishRoutingConnector(router)); context.Pipeline.Replace("MessageDrivenSubscribeTerminator", new NullSubscribeTerminator(), "handles subscribe operations"); context.Pipeline.Replace("MessageDrivenUnsubscribeTerminator", new NullUnsubscribeTerminator(), "handles ubsubscribe operations"); } if (outboundRoutingPolicy.Sends == OutboundRoutingType.Unicast) { context.Pipeline.Replace("UnicastSendRouterConnector", new SendRoutingConnector(router)); } else { context.Pipeline.Replace("UnicastSendRouterConnector", new MulticastSendRoutingConnector()); } }
public override string ToTransportAddress(LogicalAddress logicalAddress) { return(logicalAddress.EndpointInstance.Endpoint); }
string CustomTranslationRule(LogicalAddress endpointInstanceName) { throw new NotImplementedException(); }
bool Equals(LogicalAddress other) { return string.Equals(Qualifier, other.Qualifier) && Equals(EndpointInstance, other.EndpointInstance); }
public override string ToTransportAddress(LogicalAddress logicalAddress) { throw new NotImplementedException(); }
public void Initialize(ReadOnlySettings settings, TransportInfrastructure transportInfrastructure, PipelineSettings pipelineSettings) { var unicastBusConfig = settings.GetConfigSection <UnicastBusConfig>(); var conventions = settings.Get <Conventions>(); var configuredUnicastRoutes = settings.GetOrDefault <ConfiguredUnicastRoutes>(); var distributorAddress = settings.GetOrDefault <string>("LegacyDistributor.Address"); List <DistributionStrategy> distributionStrategies; if (settings.TryGet(out distributionStrategies)) { foreach (var distributionStrategy in distributionStrategies) { DistributionPolicy.SetDistributionStrategy(distributionStrategy); } } unicastBusConfig?.MessageEndpointMappings.Apply(Publishers, UnicastRoutingTable, transportInfrastructure.MakeCanonicalForm, conventions); configuredUnicastRoutes?.Apply(UnicastRoutingTable, conventions); pipelineSettings.Register(b => { var router = new UnicastSendRouter(settings.GetOrDefault <string>("BaseInputQueueName"), settings.EndpointName(), settings.InstanceSpecificQueue(), distributorAddress, 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); } }
public override string ToTransportAddress(LogicalAddress logicalAddress) { return null; }