public TransportConfigurationResult Configure(SettingsHolder settings, TransportTransactionMode transportTransactionMode) { #if !NETFRAMEWORK if (transportTransactionMode == TransportTransactionMode.TransactionScope) { NUnit.Framework.Assert.Ignore("TransactionScope not supported in .NET Core"); } #endif this.settings = settings; settings.Set(transportTransactionMode); settings.Set("NServiceBus.SharedQueue", settings.EndpointName()); var delayedDeliverySettings = new DelayedDeliverySettings(settings); delayedDeliverySettings.TableSuffix("Delayed"); var pubSubSettings = new SubscriptionSettings(); pubSubSettings.DisableSubscriptionCache(); settings.Set(pubSubSettings); connectionString = Environment.GetEnvironmentVariable("SqlServerTransportConnectionString"); if (string.IsNullOrEmpty(connectionString)) { connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True"; } var logicalAddress = LogicalAddress.CreateLocalAddress(settings.ErrorQueueAddress(), new Dictionary <string, string>()); var localAddress = settings.EndpointName(); return(new TransportConfigurationResult { TransportInfrastructure = new SqlServerTransportInfrastructure("nservicebus", settings, connectionString, () => localAddress, () => logicalAddress, false) }); }
public TransportConfigurationResult Configure(SettingsHolder settings, TransportTransactionMode transportTransactionMode) { this.settings = settings; settings.Set("NServiceBus.SharedQueue", settings.EndpointName()); settings.Set <LogicalAddress>(LogicalAddress.CreateLocalAddress(settings.EndpointName(), new Dictionary <string, string>())); var delayedDeliverySettings = new DelayedDeliverySettings(); delayedDeliverySettings.TableSuffix("Delayed"); settings.Set <DelayedDeliverySettings>(delayedDeliverySettings); return(new TransportConfigurationResult { TransportInfrastructure = new SqlServerTransport().Initialize(settings, ConnectionString) }); }
public TopologySection DetermineResourcesToCreate(QueueBindings queueBindings) { // computes the topologySectionManager var endpointName = settings.EndpointName(); var partitioningStrategy = (INamespacePartitioningStrategy)container.Resolve(typeof(INamespacePartitioningStrategy)); var addressingLogic = (AddressingLogic)container.Resolve(typeof(AddressingLogic)); var namespaces = partitioningStrategy.GetNamespaces(PartitioningIntent.Creating).ToArray(); var inputQueuePath = addressingLogic.Apply(endpointName, EntityType.Queue).Name; var entities = namespaces.Select(n => new EntityInfo { Path = inputQueuePath, Type = EntityType.Queue, Namespace = n }).ToList(); var topicPath = addressingLogic.Apply(endpointName + ".events", EntityType.Topic).Name; var topics = namespaces.Select(n => new EntityInfo { Path = topicPath, Type = EntityType.Topic, Namespace = n }).ToArray(); entities.AddRange(topics); foreach (var n in namespaces) { entities.AddRange(queueBindings.ReceivingAddresses.Select(p => new EntityInfo { Path = addressingLogic.Apply(p, EntityType.Queue).Name, Type = EntityType.Queue, Namespace = n })); // assumed errorq and auditq are in here entities.AddRange(queueBindings.SendingAddresses.Select(p => new EntityInfo { Path = addressingLogic.Apply(p, EntityType.Queue).Name, Type = EntityType.Queue, Namespace = n })); } return(new TopologySection() { Namespaces = namespaces, Entities = entities.ToArray() }); }
/// <summary> /// The database name from endpoint name. /// </summary> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static string DatabaseNameFromEndpointName(this SettingsHolder settings) { Contract.Requires(settings != null); Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result <string>())); return(settings.EndpointName().AssumedNotNullOrWhiteSpace().AsValidDatabaseName()); }
public TopologySection DetermineResourcesToCreate(QueueBindings queueBindings) { var endpointName = settings.EndpointName(); var partitioningStrategy = (INamespacePartitioningStrategy)container.Resolve(typeof(INamespacePartitioningStrategy)); var addressingLogic = (AddressingLogic)container.Resolve(typeof(AddressingLogic)); var namespaces = partitioningStrategy.GetNamespaces(PartitioningIntent.Creating).ToArray(); var inputQueuePath = addressingLogic.Apply(endpointName, EntityType.Queue).Name; var inputQueues = namespaces.Select(n => new EntityInfo { Path = inputQueuePath, Type = EntityType.Queue, Namespace = n }).ToList(); if (!topics.Any()) { BuildTopicBundles(namespaces, addressingLogic); } foreach (var n in namespaces) { inputQueues.AddRange(queueBindings.ReceivingAddresses.Select(p => new EntityInfo { Path = addressingLogic.Apply(p, EntityType.Queue).Name, Type = EntityType.Queue, Namespace = n })); inputQueues.AddRange(queueBindings.SendingAddresses.Select(p => new EntityInfo { Path = addressingLogic.Apply(p, EntityType.Queue).Name, Type = EntityType.Queue, Namespace = n })); } var entities = inputQueues.Concat(topics).ToArray(); return(new TopologySection { Namespaces = namespaces, Entities = entities }); }
public InMemoryTransportInfrastructure(SettingsHolder settings) { _endpointName = settings.EndpointName(); if (settings.TryGet(out InMemoryDatabase database)) { _inMemoryDatabase = database; } }
static string GetDelayedDeliveryTableName(SettingsHolder settings) { var delayedDeliveryTableName = settings.GetOrDefault <string>(WellKnownConfigurationKeys.DelayedDelivery.TableName); var delayedDeliveryTableNameWasNotOverridden = string.IsNullOrEmpty(delayedDeliveryTableName); if (delayedDeliveryTableNameWasNotOverridden) { delayedDeliveryTableName = GenerateDelayedDeliveryTableName(settings.EndpointName()); settings.Set(WellKnownConfigurationKeys.DelayedDelivery.TableName, delayedDeliveryTableName); } return(delayedDeliveryTableName); }
IPushMessages CreateMessagePump() { MessageConverter messageConverter; if (settings.HasSetting(SettingsKeys.CustomMessageIdStrategy)) { messageConverter = new MessageConverter(settings.Get <Func <BasicDeliverEventArgs, string> >(SettingsKeys.CustomMessageIdStrategy)); } else { messageConverter = new MessageConverter(); } string hostDisplayName; if (!settings.TryGet("NServiceBus.HostInformation.DisplayName", out hostDisplayName)) { hostDisplayName = Support.RuntimeEnvironment.MachineName; } var consumerTag = $"{hostDisplayName} - {settings.EndpointName()}"; var queuePurger = new QueuePurger(connectionFactory); TimeSpan timeToWaitBeforeTriggeringCircuitBreaker; if (!settings.TryGet(SettingsKeys.TimeToWaitBeforeTriggeringCircuitBreaker, out timeToWaitBeforeTriggeringCircuitBreaker)) { timeToWaitBeforeTriggeringCircuitBreaker = TimeSpan.FromMinutes(2); } int prefetchMultiplier; if (!settings.TryGet(SettingsKeys.PrefetchMultiplier, out prefetchMultiplier)) { prefetchMultiplier = 3; } ushort prefetchCount; if (!settings.TryGet(SettingsKeys.PrefetchCount, out prefetchCount)) { prefetchCount = 0; } return(new MessagePump(connectionFactory, messageConverter, consumerTag, channelProvider, queuePurger, timeToWaitBeforeTriggeringCircuitBreaker, prefetchMultiplier, prefetchCount)); }
public RabbitMQTransportInfrastructure(SettingsHolder settings, string connectionString) { this.settings = settings; var endpointName = settings.EndpointName(); var connectionConfiguration = ConnectionConfiguration.Create(connectionString, endpointName); settings.TryGet(SettingsKeys.ClientCertificateCollection, out X509Certificate2Collection clientCertificateCollection); settings.TryGet(SettingsKeys.DisableRemoteCertificateValidation, out bool disableRemoteCertificateValidation); settings.TryGet(SettingsKeys.UseExternalAuthMechanism, out bool useExternalAuthMechanism); settings.TryGet(SettingsKeys.HeartbeatInterval, out TimeSpan? heartbeatInterval); settings.TryGet(SettingsKeys.NetworkRecoveryInterval, out TimeSpan? networkRecoveryInterval); connectionFactory = new ConnectionFactory(endpointName, connectionConfiguration, clientCertificateCollection, disableRemoteCertificateValidation, useExternalAuthMechanism, heartbeatInterval, networkRecoveryInterval); routingTopology = CreateRoutingTopology(); channelProvider = new ChannelProvider(connectionFactory, connectionConfiguration.RetryDelay, routingTopology); }
public Task Init(Func <MessageContext, Task> onMessage, Func <ErrorContext, Task <ErrorHandleResult> > onError, CriticalError criticalError, PushSettings settings) { this.inputQueue = settings.InputQueue; var consumerHolder = new ConsumerHolder(connectionString, inputQueue, settings, settingsHolder, onMessage, onError, criticalError); consumerHolderList.Add(consumerHolder); if (inputQueue == settingsHolder.EndpointName()) { mainConsumer = consumerHolder; this.onError = onError; this.onMessage = onMessage; eventsConsumer = new ConsumerHolder(connectionString, inputQueue, settings, settingsHolder, onMessage, onError, criticalError, true); consumerHolderList.Add(eventsConsumer); } return(Task.FromResult(0)); }
public RabbitMQTransportInfrastructure(SettingsHolder settings, string connectionString) { this.settings = settings; var endpointName = settings.EndpointName(); var connectionConfiguration = ConnectionConfiguration.Create(connectionString, endpointName); settings.TryGet(SettingsKeys.ClientCertificates, out X509CertificateCollection clientCertificates); settings.TryGet(SettingsKeys.DisableRemoteCertificateValidation, out bool disableRemoteCertificateValidation); settings.TryGet(SettingsKeys.UseExternalAuthMechanism, out bool useExternalAuthMechanism); connectionFactory = new ConnectionFactory(endpointName, connectionConfiguration, clientCertificates, disableRemoteCertificateValidation, useExternalAuthMechanism); routingTopology = CreateRoutingTopology(); if (!settings.TryGet(SettingsKeys.UsePublisherConfirms, out bool usePublisherConfirms)) { usePublisherConfirms = true; } channelProvider = new ChannelProvider(connectionFactory, connectionConfiguration.RetryDelay, routingTopology, usePublisherConfirms); }
public RabbitMQTransportInfrastructure(SettingsHolder settings, string connectionString) { this.settings = settings; var connectionConfiguration = ConnectionConfiguration.Create(connectionString, settings.EndpointName()); X509CertificateCollection clientCertificates; settings.TryGet(SettingsKeys.ClientCertificates, out clientCertificates); connectionFactory = new ConnectionFactory(connectionConfiguration, clientCertificates); routingTopology = CreateRoutingTopology(); routingTopologySupportsDelayedDelivery = routingTopology is ISupportDelayedDelivery; settings.Set(SettingsKeys.RoutingTopologySupportsDelayedDelivery, routingTopologySupportsDelayedDelivery); bool usePublisherConfirms; if (!settings.TryGet(SettingsKeys.UsePublisherConfirms, out usePublisherConfirms)) { usePublisherConfirms = true; } settings.TryGet(SettingsKeys.DisableTimeoutManager, out disableTimeoutManager); bool allEndpointsSupportDelayedDelivery; settings.TryGet(SettingsKeys.AllEndpointsSupportDelayedDelivery, out allEndpointsSupportDelayedDelivery); channelProvider = new ChannelProvider(connectionFactory, routingTopology, usePublisherConfirms, allEndpointsSupportDelayedDelivery); RequireOutboxConsent = false; }
public RabbitMQTransportInfrastructure(SettingsHolder settings, string connectionString) { this.settings = settings; var connectionConfiguration = ConnectionConfiguration.Create(connectionString, settings.EndpointName()); X509CertificateCollection clientCertificates; settings.TryGet(SettingsKeys.ClientCertificates, out clientCertificates); connectionFactory = new ConnectionFactory(connectionConfiguration, clientCertificates); routingTopology = CreateRoutingTopology(); var routingTopologySupportsDelayedDelivery = routingTopology is ISupportDelayedDelivery; settings.Set(SettingsKeys.RoutingTopologySupportsDelayedDelivery, routingTopologySupportsDelayedDelivery); if (routingTopologySupportsDelayedDelivery) { var timeoutManagerFeatureDisabled = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Disabled; var sendOnlyEndpoint = settings.GetOrDefault <bool>(coreSendOnlyEndpointKey); if (timeoutManagerFeatureDisabled || sendOnlyEndpoint) { settings.Set(SettingsKeys.DisableTimeoutManager, true); } } bool usePublisherConfirms; if (!settings.TryGet(SettingsKeys.UsePublisherConfirms, out usePublisherConfirms)) { usePublisherConfirms = true; } channelProvider = new ChannelProvider(connectionFactory, routingTopology, usePublisherConfirms); RequireOutboxConsent = false; }
public EmailTransportMessagePump(SettingsHolder settings) { _endpointName = settings.EndpointName(); _settings = settings; }