public static AgainstNegative ( [ argumentName, System.TimeSpan value ) : void | ||
argumentName | [ | |
value | System.TimeSpan | |
return | void |
/// <summary> /// Number of retries when operation is throttled. /// <remarks>Default is 5 attempts.</remarks> /// </summary> public AzureServiceBusMessageSenderSettings RetryAttemptsOnThrottle(int count) { Guard.AgainstNegative(nameof(count), count); settings.Set(WellKnownConfigurationKeys.Connectivity.MessageSenders.RetryAttemptsOnThrottle, count); return(this); }
/// <summary> /// Time period to wait until next attempt is made after operation is throttled. /// <remarks>Default is 10 seconds.</remarks> /// </summary> public AzureServiceBusMessageSenderSettings BackOffTimeOnThrottle(TimeSpan backoffTime) { Guard.AgainstNegative(nameof(backoffTime), backoffTime); settings.Set(WellKnownConfigurationKeys.Connectivity.MessageSenders.BackOffTimeOnThrottle, backoffTime); return(this); }
/// <summary> /// Set the number of retries and time increase between them for messages failing to be sent through the gateway. /// </summary> /// <param name="numberOfRetries">The total number of retries to do. 0 means no retry.</param> /// <param name="timeIncrease">The time to wait between each retry.</param> public void Retries(int numberOfRetries, TimeSpan timeIncrease) { Guard.AgainstNegative(nameof(numberOfRetries), numberOfRetries); Guard.AgainstNegative(nameof(timeIncrease), timeIncrease); SetDefaultRetryPolicySettings(numberOfRetries, timeIncrease); }
/// <summary> /// Delays the delivery of the message with the specified delay. /// </summary> /// <param name="options">The options being extended.</param> /// <param name="delay">The requested delay.</param> public static void DelayDeliveryWith(this SendOptions options, TimeSpan delay) { Guard.AgainstNull(nameof(options), options); Guard.AgainstNegative(nameof(delay), delay); options.GetExtensions().AddDeliveryConstraint(new DelayDeliveryWith(delay)); }
/// <summary> /// Creates a new delayed retries configuration. /// </summary> /// <param name="maxNumberOfRetries">The maximum number of delayed retries.</param> /// <param name="timeIncrease">The time of increase for individual delayed retries.</param> public DelayedConfig(int maxNumberOfRetries, TimeSpan timeIncrease) { Guard.AgainstNegative(nameof(maxNumberOfRetries), maxNumberOfRetries); Guard.AgainstNegative(nameof(timeIncrease), timeIncrease); MaxNumberOfRetries = maxNumberOfRetries; TimeIncrease = timeIncrease; }
/// <summary> /// Configures the delay interval increase for each failed Delayed Retries attempt. /// </summary> public DelayedRetriesSettings TimeIncrease(TimeSpan timeIncrease) { Guard.AgainstNegative(nameof(timeIncrease), timeIncrease); Settings.Set(Recoverability.DelayedRetriesTimeIncrease, timeIncrease); return(this); }
/// <summary> /// Configures the number of times a message should be retried with a delay after failing Immediate Retries. /// </summary> public DelayedRetriesSettings NumberOfRetries(int numberOfRetries) { Guard.AgainstNegative(nameof(numberOfRetries), numberOfRetries); Settings.Set(Recoverability.NumberOfDelayedRetries, numberOfRetries); return(this); }
/// <summary> /// Overrides the default prefetch count calculation with the specified value. /// </summary> /// <param name="transportExtensions"></param> /// <param name="prefetchCount">The prefetch count to use.</param> public static TransportExtensions <AzureServiceBusTransport> PrefetchCount(this TransportExtensions <AzureServiceBusTransport> transportExtensions, int prefetchCount) { Guard.AgainstNegative(nameof(prefetchCount), prefetchCount); transportExtensions.GetSettings().Set(SettingsKeys.PrefetchCount, prefetchCount); return(transportExtensions); }
/// <summary> /// Delays the delivery of the message with the specified delay. /// </summary> /// <param name="options">The options being extended.</param> /// <param name="delay">The requested delay.</param> public static void DelayDeliveryWith(this SendOptions options, TimeSpan delay) { Guard.AgainstNull(nameof(options), options); Guard.AgainstNegative(nameof(delay), delay); if (options.DispatchProperties.DoNotDeliverBefore != null) { throw new InvalidOperationException($"The options are already configured for delayed delivery by the '{nameof(DoNotDeliverBefore)}' API."); } options.DispatchProperties.DelayDeliveryWith = new DelayDeliveryWith(delay); }
/// <summary> /// Delays the delivery of the message with the specified delay. /// </summary> /// <param name="options">The options being extended.</param> /// <param name="delay">The requested delay.</param> public static void DelayDeliveryWith(this SendOptions options, TimeSpan delay) { Guard.AgainstNull(nameof(options), options); Guard.AgainstNegative(nameof(delay), delay); if (options.GetExtensions().TryGetDeliveryConstraint(out DoNotDeliverBefore _)) { throw new InvalidOperationException($"The options are already configured for delayed delivery by the '{nameof(DoNotDeliverBefore)}' API."); } options.GetExtensions().AddDeliveryConstraint(new DelayDeliveryWith(delay)); }
/// <summary> /// Configures audit settings. /// </summary> /// <param name="config">The <see cref="EndpointConfiguration" /> instance to apply the settings to.</param> /// <param name="auditQueue">The name of the audit queue to use.</param> /// <param name="timeToBeReceived">The message expiration time span to use for messages sent to the audit queue.</param> public static void AuditProcessedMessagesTo(this EndpointConfiguration config, string auditQueue, TimeSpan?timeToBeReceived = null) { Guard.AgainstNull(nameof(config), config); Guard.AgainstNullAndEmpty(nameof(auditQueue), auditQueue); if (timeToBeReceived != null) { Guard.AgainstNegative(nameof(timeToBeReceived), timeToBeReceived.Value); } config.Settings.Set <AuditConfigReader.Result>(new AuditConfigReader.Result { Address = auditQueue, TimeToBeReceived = timeToBeReceived }); }
} // method // The following methods are exact copies of the methods in TextReader, // extracting by disassembling it in Reflector public override int Read(char[] buffer, int index, int count) { Guard.AgainstNull(nameof(buffer), buffer); Guard.AgainstNegative(nameof(index), index); Guard.AgainstNegative(nameof(count), count); if (buffer.Length - index < count) { throw new ArgumentException(); } var number = 0; do { var nextNumber = Read(); if (nextNumber == -1) { return(number); } buffer[index + number++] = (char)nextNumber; } while (number < count); return(number); }
/// <summary> /// A critical error is raised when timeout retrieval fails. /// By default we wait for 2 seconds for the storage to come back. /// This method allows to change the default and extend the wait time. /// </summary> /// <param name="config">The <see cref="EndpointConfiguration" /> instance to apply the settings to.</param> /// <param name="timeToWait">Time to wait before raising a critical error.</param> public static void TimeToWaitBeforeTriggeringCriticalErrorOnTimeoutOutages(this EndpointConfiguration config, TimeSpan timeToWait) { Guard.AgainstNull(nameof(config), config); Guard.AgainstNegative(nameof(timeToWait), timeToWait); config.Settings.Set("TimeToWaitBeforeTriggeringCriticalErrorForTimeoutPersisterReceiver", timeToWait); }
/// <summary> /// Configures the amount of times a message should be immediately retried after failing /// before escalating to Delayed Retries. /// </summary> /// <param name="numberOfRetries">The number of times to immediately retry a failed message.</param> public void NumberOfRetries(int numberOfRetries) { Guard.AgainstNegative(nameof(numberOfRetries), numberOfRetries); Settings.Set(RecoverabilityComponent.NumberOfImmediateRetries, numberOfRetries); }
/// <summary> /// Message size padding percentage used for sending batched messages. /// <remarks>Default is 5%.</remarks> /// </summary> public AzureServiceBusMessageSenderSettings MessageSizePaddingPercentage(int percentage) { Guard.AgainstNegative(nameof(percentage), percentage); settings.Set(WellKnownConfigurationKeys.Connectivity.MessageSenders.MessageSizePaddingPercentage, percentage); return(this); }
public static TransportExtensions <AzureServiceBusTransport> PrefetchCount(this TransportExtensions <AzureServiceBusTransport> transportExtensions, int prefetchCount) { Guard.AgainstNegative(nameof(prefetchCount), prefetchCount); transportExtensions.Transport.PrefetchCount = prefetchCount; return(transportExtensions); }
/// <summary> /// Creates a new delayed retry recoverability action. /// </summary> /// <param name="timeSpan">Delivery delay.</param> /// <returns>Delayed retry action.</returns> public static DelayedRetry DelayedRetry(TimeSpan timeSpan) { Guard.AgainstNegative(nameof(timeSpan), timeSpan); return(new DelayedRetry(timeSpan)); }