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)));
 }
        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.");
                        }
                    }
                }
            }
        }