static void MatchSettingsToConsistencyRequirements(SettingsHolder settings) { if (settings.HasSetting <TransportTransactionMode>()) { var required = settings.Get <TransportTransactionMode>(); if (required > TransportTransactionMode.SendsAtomicWithReceive) { throw new InvalidOperationException($"Azure Service Bus transport doesn't support the required transaction mode {required}."); } if (required > settings.SupportedTransactionMode()) { throw new InvalidOperationException($"Azure Service Bus transport doesn't support the required transaction mode {required}, for the given configuration settings."); } if (required < settings.SupportedTransactionMode()) { if (required < TransportTransactionMode.SendsAtomicWithReceive) { // turn send via off so that sends are not atomic settings.Set(WellKnownConfigurationKeys.Connectivity.SendViaReceiveQueue, false); } if (required == TransportTransactionMode.None) { // immediately delete after receive settings.Set(WellKnownConfigurationKeys.Connectivity.MessageReceivers.ReceiveMode, ReceiveMode.ReceiveAndDelete); // override the default for prefetch count, but user code can still take precedence settings.SetDefault(WellKnownConfigurationKeys.Connectivity.MessageReceivers.PrefetchCount, 0); if (!settings.HasExplicitValue(WellKnownConfigurationKeys.Connectivity.MessageReceivers.PrefetchCount)) { logger.Warn("Default value for message receiver's PrefetchCount was reduced to zero to avoid message loss with ReceiveAndDelete receive mode. To enforce prefetch, use the configuration API to set the value explicitly."); } } } } }
protected AzureServiceBusTransportInfrastructure(SettingsHolder settings) { TransactionMode = settings.SupportedTransactionMode(); Settings = settings; TopologySettings = settings.GetOrCreate <TopologySettings>(); var individualizationStrategyType = (Type)Settings.Get(WellKnownConfigurationKeys.Topology.Addressing.Individualization.Strategy); individualization = individualizationStrategyType.CreateInstance <IIndividualizationStrategy>(Settings); var compositionStrategyType = (Type)Settings.Get(WellKnownConfigurationKeys.Topology.Addressing.Composition.Strategy); var compositionStrategy = compositionStrategyType.CreateInstance <ICompositionStrategy>(Settings); var sanitizationStrategyType = (Type)Settings.Get(WellKnownConfigurationKeys.Topology.Addressing.Sanitization.Strategy); var sanitizationStrategy = sanitizationStrategyType.CreateInstance <ISanitizationStrategy>(Settings); addressingLogic = new AddressingLogic(sanitizationStrategy, compositionStrategy); }
public override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString) { // override core default serialization settings.SetDefault(WellKnownConfigurationKeys.Core.MainSerializerSettingsKey, Tuple.Create <SerializationDefinition, SettingsHolder>(new JsonSerializer(), new SettingsHolder())); var topology = GetConfiguredTopology(settings); topology.Initialize(settings); if (!string.IsNullOrEmpty(connectionString)) { RegisterConnectionStringAsNamespace(connectionString, settings); } MatchSettingsToConsistencyRequirements(settings); SetConnectivityMode(settings); return(new AzureServiceBusTransportInfrastructure(topology, settings.SupportedTransactionMode())); }
static MessageReceiverNotifierSettings BuildMessageReceiverNotifierSettings(SettingsHolder settings) { // default values set by DefaultConfigurationValues.Apply - shouldn't hardcode those here, so OK to use settings return(new MessageReceiverNotifierSettings( ReceiveMode.PeekLock, settings.HasExplicitValue <TransportTransactionMode>() ? settings.Get <TransportTransactionMode>() : settings.SupportedTransactionMode(), settings.Get <TimeSpan>(WellKnownConfigurationKeys.Connectivity.MessageReceivers.AutoRenewTimeout), settings.Get <int>(WellKnownConfigurationKeys.Connectivity.NumberOfClientsPerEntity))); }