public static StartupCheckResult CheckForInvalidSettings(SettingsHolder settings) { var routingTopologySupportsDelayedDelivery = settings.GetOrDefault <bool>(SettingsKeys.RoutingTopologySupportsDelayedDelivery); var timeoutManagerDisabled = settings.GetOrDefault <bool>(SettingsKeys.DisableTimeoutManager); var externalTimeoutManagerAddress = settings.GetOrDefault <string>(coreExternalTimeoutManagerAddressKey) != null; var timeoutManagerFeatureActive = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Active; if (!routingTopologySupportsDelayedDelivery && timeoutManagerDisabled) { return(StartupCheckResult.Failed($"Cannot disable the timeout manager when the specified routing topology does not implement {nameof(ISupportDelayedDelivery)}.")); } if (routingTopologySupportsDelayedDelivery) { if (externalTimeoutManagerAddress) { return(StartupCheckResult.Failed("An external timeout manager address cannot be configured because the timeout manager is not being used for delayed delivery.")); } if (!timeoutManagerDisabled && !timeoutManagerFeatureActive) { return(StartupCheckResult.Failed("The timeout manager is not active, but the transport has not been properly configured for this. " + "Use 'EndpointConfiguration.UseTransport<RabbitMQTransport>().DelayedDelivery().DisableTimeoutManager()' to ensure delayed messages can be sent properly.")); } } return(StartupCheckResult.Success); }
public static StartupCheckResult CheckForInvalidSettings(SettingsHolder settings) { var timeoutManagerShouldBeEnabled = settings.GetOrDefault <bool>(SettingsKeys.EnableTimeoutManager); var timeoutManagerFeatureActive = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Active; if (timeoutManagerShouldBeEnabled && !timeoutManagerFeatureActive) { return(StartupCheckResult.Failed("The transport has been configured to enable the timeout manager, but the timeout manager is not active." + "Ensure that the timeout manager is active or remove the call to 'EndpointConfiguration.UseTransport<RabbitMQTransport>().DelayedDelivery().EnableTimeoutManager()'.")); } return(StartupCheckResult.Success); }
public TransportInfrastructure(SettingsHolder settings, string connectionString) { connectionConfiguration = new ConnectionStringParser().Parse(connectionString); subscriptionManager = new Lazy <SubscriptionManager>(() => { var disableCaching = settings.GetOrDefault <bool>("NServiceBus.EventStore.DisableExchangeCaching"); return(new SubscriptionManager(connectionConfiguration, settings.LocalAddress(), !disableCaching)); }); timeoutProcessor = new Lazy <TimeoutProcessor>(() => { var uniqueId = settings.GetOrDefault <string>("NServiceBus.EventStore.TimeoutProcessorId") ?? Guid.NewGuid().ToString(); return(new TimeoutProcessor(() => DateTime.UtcNow, uniqueId, connectionConfiguration)); }); }
PipelineCollection CreateIncomingPipelines() { PipelineCollection pipelineCollection; if (settings.GetOrDefault <bool>("Endpoint.SendOnly")) { pipelineCollection = new PipelineCollection(Enumerable.Empty <TransportReceiver>()); } else { var pipelines = BuildPipelines().ToArray(); pipelineCollection = new PipelineCollection(pipelines); } return(pipelineCollection); }
internal AzureStorageQueueInfrastructure(SettingsHolder settings, string connectionString) { this.settings = settings; this.connectionString = connectionString; settings.SetDefault(WellKnownConfigurationKeys.DelayedDelivery.EnableTimeoutManager, true); if (!settings.IsFeatureEnabled(typeof(TimeoutManager)) || settings.GetOrDefault <bool>("Endpoint.SendOnly")) { // TimeoutManager is already not used. Indicate to Native Delayed Delivery that we're not in the hybrid mode. settings.Set(WellKnownConfigurationKeys.DelayedDelivery.EnableTimeoutManager, false); } delayedDelivery = new NativeDelayDelivery(connectionString, GetDelayedDeliveryTableName(settings), settings.GetOrDefault <bool>(WellKnownConfigurationKeys.DelayedDelivery.DisableDelayedDelivery)); addressGenerator = new QueueAddressGenerator(settings.GetOrDefault <Func <string, string> >(WellKnownConfigurationKeys.QueueSanitizer)); }
static int GetNumberOfImmediateRetries(SettingsHolder settings) { var maxDeliveryCount = settings.GetOrDefault <int>(WellKnownConfigurationKeys.Core.RecoverabilityNumberOfImmediateRetries); maxDeliveryCount = maxDeliveryCount > 0 ? maxDeliveryCount + 1 : 10; return(maxDeliveryCount); }
bool UserSuppressedTimeoutPersistenceWarning() { if (settingsHolder.HasSetting(SuppressOutdatedTimeoutPersistenceWarning)) { return(settingsHolder.GetOrDefault <bool>(SuppressOutdatedTimeoutPersistenceWarning)); } var appSetting = ConfigurationManager.AppSettings[SuppressOutdatedTimeoutPersistenceWarning]; if (appSetting != null) { return(bool.Parse(appSetting)); } return(false); }
public static StartupCheckResult CheckForInvalidSettings(SettingsHolder settings) { var externalTimeoutManagerAddress = settings.GetOrDefault <string>("NServiceBus.ExternalTimeoutManagerAddress") != null; if (externalTimeoutManagerAddress) { return(StartupCheckResult.Failed("An external timeout manager address cannot be configured because the timeout manager is not being used for delayed delivery.")); } var sendOnlyEndpoint = settings.GetOrDefault <bool>("Endpoint.SendOnly"); if (sendOnlyEndpoint) { return(StartupCheckResult.Failed("Native delayed delivery is only supported for endpoints capable of receiving messages.")); } return(StartupCheckResult.Success); }
public override void Initialize() { Configure.Component <MessageMapper>(DependencyLifecycle.SingleInstance); Configure.Component <SystemXmlMessageSerializer>(DependencyLifecycle.SingleInstance) .ConfigureProperty(p => p.SkipWrappingElementForSingleMessages, !SettingsHolder.GetOrDefault <bool>("SerializationSettings.WrapSingleMessages")); SettingsHolder.ApplyTo <SystemXmlMessageSerializer>(); }
public override void Initialize() { if (!SettingsHolder.GetOrDefault <bool>("ScaleOut.UseSingleBrokerQueue")) { Address.InitializeLocalAddress(Address.Local.Queue + "." + Address.Local.Machine); } var connectionString = SettingsHolder.Get <string>("NServiceBus.Transport.ConnectionString"); var connectionConfiguration = new ConnectionStringParser().Parse(connectionString); NServiceBus.Configure.Instance.Configurer.RegisterSingleton <IConnectionConfiguration>(connectionConfiguration); NServiceBus.Configure.Component <RabbitMqDequeueStrategy>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(p => p.PurgeOnStartup, ConfigurePurging.PurgeRequested) .ConfigureProperty(p => p.PrefetchCount, connectionConfiguration.PrefetchCount); NServiceBus.Configure.Component <RabbitMqUnitOfWork>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(p => p.UsePublisherConfirms, connectionConfiguration.UsePublisherConfirms) .ConfigureProperty(p => p.MaxWaitTimeForConfirms, connectionConfiguration.MaxWaitTimeForConfirms); NServiceBus.Configure.Component <RabbitMqMessageSender>(DependencyLifecycle.InstancePerCall); NServiceBus.Configure.Component <RabbitMqMessagePublisher>(DependencyLifecycle.InstancePerCall); NServiceBus.Configure.Component <RabbitMqSubscriptionManager>(DependencyLifecycle.SingleInstance) .ConfigureProperty(p => p.EndpointQueueName, Address.Local.Queue); NServiceBus.Configure.Component <RabbitMqQueueCreator>(DependencyLifecycle.InstancePerCall); InfrastructureServices.Enable <IRoutingTopology>(); InfrastructureServices.Enable <IManageRabbitMqConnections>(); }
public void FinalizeConfiguration() { if (SettingsHolder.GetOrDefault <bool>("UnicastBus.AutoSubscribe")) { InfrastructureServices.Enable <IAutoSubscriptionStrategy>(); } }
internal SqlServerTransportInfrastructure(QueueAddressTranslator addressTranslator, SettingsHolder settings, string connectionString) { this.addressTranslator = addressTranslator; this.settings = settings; this.connectionString = connectionString; schemaAndCatalogSettings = settings.GetOrCreate <EndpointSchemaAndCatalogSettings>(); delayedDeliverySettings = settings.GetOrDefault <DelayedDeliverySettings>(); var timeoutManagerFeatureDisabled = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Disabled; if (delayedDeliverySettings != null && timeoutManagerFeatureDisabled) { delayedDeliverySettings.DisableTimeoutManagerCompatibility(); } //HINT: this flag indicates that user need to explicitly turn outbox in configuration. RequireOutboxConsent = true; }
private static void CustomizeAddress() { Address.IgnoreMachineName(); if (!SettingsHolder.GetOrDefault <bool>("ScaleOut.UseSingleBrokerQueue")) { Address.InitializeLocalAddress(Address.Local.Queue + "." + Address.Local.Machine); } }
static void CheckIfSettingsWhereUsedToCreateAnotherEndpoint(SettingsHolder settings) { if (settings.GetOrDefault <bool>("UsedToCreateEndpoint")) { throw new ArgumentException("This EndpointConfiguration was already used for starting an endpoint. Each endpoint requires a new EndpointConfiguration."); } settings.Set("UsedToCreateEndpoint", true); }
internal AzureStorageQueueInfrastructure(SettingsHolder settings, string connectionString) { this.settings = settings; this.connectionString = connectionString; serializer = BuildSerializer(settings); var timeoutManagerFeatureDisabled = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Disabled; var sendOnlyEndpoint = settings.GetOrDefault <bool>("Endpoint.SendOnly"); if (timeoutManagerFeatureDisabled || sendOnlyEndpoint) { // TimeoutManager is already not used. Indicate to Native Delayed Delivery that we're not in the hybrid mode. settings.Set(WellKnownConfigurationKeys.DelayedDelivery.DisableTimeoutManager, true); } delayedDelivery = new NativeDelayDelivery(connectionString, GetDelayedDeliveryTableName(settings)); addressGenerator = new QueueAddressGenerator(settings.GetOrDefault <Func <string, string> >(WellKnownConfigurationKeys.QueueSanitizer)); }
static ITopology GetConfiguredTopology(SettingsHolder settings) { var configuredTopology = settings.GetOrDefault <ITopology>(); if (configuredTopology == null) { throw new Exception("Azure Service Bus transport requires a topology to be specified. Use `.UseTopology<ITopology>()` configuration API to specify topology to use."); } return(configuredTopology); }
/// <summary> /// <see cref="TransportDefinition.Initialize" /> /// </summary> public override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString) { settings.TryGet(SettingsKeys.DefaultSchemaSettingsKey, out string defaultSchemaOverride); var queueSchemaSettings = settings.GetOrDefault <QueueSchemaAndCatalogSettings>(); var catalog = GetDefaultCatalog(settings, connectionString); var addressParser = new QueueAddressTranslator(catalog, "dbo", defaultSchemaOverride, queueSchemaSettings); return(new SqlServerTransportInfrastructure(addressParser, settings, connectionString)); }
public void IsEnabled() { Configure configure = Configure.With(); #region IsDistributorEnabled bool isDistributorEnabled = SettingsHolder.GetOrDefault <bool>("Distributor.Enabled"); #endregion #region IsWorkerEnabled bool isWorkerEnabled = SettingsHolder.GetOrDefault <bool>("Worker.Enabled"); #endregion }
public TestTransportInfrastructure(SettingsHolder settings) { this.settings = settings; if (!settings.TryGet(StorageLocationKey, out storagePath)) { var solutionRoot = FindSolutionRoot(); storagePath = Path.Combine(solutionRoot, ".learningtransport"); } brokerName = settings.GetOrDefault <string>(BrokerNameKey) ?? ""; var errorQueueAddress = settings.ErrorQueueAddress(); PathChecker.ThrowForBadPath(errorQueueAddress, "ErrorQueueAddress"); OutboundRoutingPolicy = settings.GetOrDefault <bool>(NoNativePubSub) ? new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Unicast, OutboundRoutingType.Unicast) : new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Multicast, OutboundRoutingType.Unicast); }
internal SqlServerTransportInfrastructure(QueueAddressTranslator addressTranslator, SettingsHolder settings, string connectionString) { this.addressTranslator = addressTranslator; this.settings = settings; this.connectionString = connectionString; schemaAndCatalogSettings = settings.GetOrCreate <EndpointSchemaAndCatalogSettings>(); delayedDeliverySettings = settings.GetOrDefault <DelayedDeliverySettings>(); var timeoutManagerFeatureDisabled = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Disabled; diagnostics.Add("NServiceBus.Transport.SqlServer.TimeoutManager", new { FeatureEnabled = !timeoutManagerFeatureDisabled }); if (delayedDeliverySettings != null && timeoutManagerFeatureDisabled) { delayedDeliverySettings.DisableTimeoutManagerCompatibility(); } }
/// <summary> /// Initializes the transport infrastructure for msmq. /// </summary> /// <param name="settings">The settings.</param> /// <param name="connectionString">The connection string.</param> /// <returns>the transport infrastructure for msmq.</returns> public override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString) { Guard.AgainstNull(nameof(settings), settings); string errorQueue; if (!settings.GetOrDefault <bool>("Endpoint.SendOnly") && !settings.TryGetExplicitlyConfiguredErrorQueueAddress(out errorQueue)) { throw new Exception("Faults forwarding requires an error queue to be specified using 'EndpointConfiguration.SendFailedMessagesTo()'"); } settings.EnableFeature(typeof(InstanceMappingFileFeature)); var msmqSettings = connectionString != null ? new MsmqConnectionStringBuilder(connectionString) .RetrieveSettings() : new MsmqSettings(); msmqSettings.UseDeadLetterQueueForMessagesWithTimeToBeReceived = settings.GetOrDefault <bool>(UseDeadLetterQueueForMessagesWithTimeToBeReceived); settings.Set <MsmqSettings>(msmqSettings); return(new MsmqTransportInfrastructure(settings)); }
/// <summary> /// Initializes the transport infrastructure for msmq. /// </summary> /// <param name="settings">The settings.</param> /// <param name="connectionString">The connection string.</param> /// <returns>the transport infrastructure for msmq.</returns> public override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString) { settings.EnableFeature(typeof(InstanceMappingFileFeature)); var msmqSettings = connectionString != null ? new MsmqConnectionStringBuilder(connectionString) .RetrieveSettings() : new MsmqSettings(); msmqSettings.UseDeadLetterQueueForMessagesWithTimeToBeReceived = settings.GetOrDefault <bool>(UseDeadLetterQueueForMessagesWithTimeToBeReceived); settings.Set <MsmqSettings>(msmqSettings); return(new MsmqTransportInfrastructure(settings)); }
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; }
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); }
void IsEnabled() { #region IsDistributorEnabled var isDistributorEnabled = SettingsHolder.GetOrDefault <bool>("Distributor.Enabled"); #endregion #region IsWorkerEnabled var isWorkerEnabled = SettingsHolder.GetOrDefault <bool>("Worker.Enabled"); #endregion }
internal SqlServerTransportInfrastructure(string catalog, SettingsHolder settings, string connectionString, Func <string> localAddress, Func <LogicalAddress> logicalAddress, bool isEncrypted) { this.settings = settings; this.connectionString = connectionString; this.localAddress = localAddress; this.logicalAddress = logicalAddress; this.isEncrypted = isEncrypted; if (settings.HasSetting(SettingsKeys.DisableNativePubSub)) { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Unicast, OutboundRoutingType.Unicast); } else { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Multicast, OutboundRoutingType.Unicast); } settings.TryGet(SettingsKeys.DefaultSchemaSettingsKey, out string defaultSchemaOverride); var queueSchemaSettings = settings.GetOrDefault <QueueSchemaAndCatalogSettings>(); addressTranslator = new QueueAddressTranslator(catalog, "dbo", defaultSchemaOverride, queueSchemaSettings); tableBasedQueueCache = new TableBasedQueueCache(addressTranslator, !isEncrypted); connectionFactory = CreateConnectionFactory(); //Configure the schema and catalog for logical endpoint-based routing var schemaAndCatalogSettings = settings.GetOrCreate <EndpointSchemaAndCatalogSettings>(); settings.GetOrCreate <EndpointInstances>().AddOrReplaceInstances("SqlServer", schemaAndCatalogSettings.ToEndpointInstances()); var pubSubSettings = settings.GetOrCreate <SubscriptionSettings>(); var subscriptionTableName = pubSubSettings.SubscriptionTable.Qualify(defaultSchemaOverride ?? "dbo", catalog); // necessary evil for acceptance tests if (settings.TryGet <Action <string> >(SettingsKeys.SubscriptionTableQuotedQualifiedNameSetter, out var action)) { action(subscriptionTableName.QuotedQualifiedName); } subscriptionStore = new PolymorphicSubscriptionStore(new SubscriptionTable(subscriptionTableName.QuotedQualifiedName, connectionFactory)); var timeToCacheSubscriptions = pubSubSettings.TimeToCacheSubscriptions; if (timeToCacheSubscriptions.HasValue) { subscriptionStore = new CachedSubscriptionStore(subscriptionStore, timeToCacheSubscriptions.Value); } var subscriptionTableCreator = new SubscriptionTableCreator(subscriptionTableName, connectionFactory); settings.Set(subscriptionTableCreator); }
void IsEnabled(Configure configure) { #region IsDistributorEnabled bool isDistributorEnabled = SettingsHolder.GetOrDefault <bool>("Distributor.Enabled"); #endregion #region IsWorkerEnabled bool isWorkerEnabled = SettingsHolder.GetOrDefault <bool>("Worker.Enabled"); #endregion }
public override void Initialize() { var transportDefinition = SettingsHolder.GetOrDefault <TransportDefinition>("NServiceBus.Transport.SelectedTransport"); if (transportDefinition != null && transportDefinition.HasNativePubSubSupport) { Logger.WarnFormat("The StorageDrivenPublisher feature is enabled but the transport has native pub/sub capabilities. Feature will not be initialized. This is most likely happening because you're specifying the As_a_Publisher role which is only relevant for transports without native pub/sub like Msmq, SqlServer etc"); return; } Configure.Component <Unicast.Publishing.StorageDrivenPublisher>(DependencyLifecycle.InstancePerCall); InfrastructureServices.Enable <ISubscriptionStorage>(); }
public void Run() { if (Configure.Instance.Configurer.HasComponent <ISendMessages>()) { return; } if (SettingsHolder.GetOrDefault <TransportDefinition>("NServiceBus.Transport.SelectedTransport") != null) { return; } Configure.Instance.UseTransport <Msmq>(); }
public ConnectionConfiguration() { // set default values Port = DefaultPort; VirtualHost = "/"; UserName = "******"; Password = "******"; RequestedHeartbeat = DefaultHeartBeatInSeconds; PrefetchCount = DefaultPrefetchCount; UsePublisherConfirms = SettingsHolder.GetOrDefault <bool>("Endpoint.DurableMessages"); MaxWaitTimeForConfirms = DefaultWaitTimeForConfirms; MaxRetries = 5; RetryDelay = TimeSpan.FromSeconds(10); SetDefaultClientProperties(); }