public void ProcessResult(RawMessage message, ITransport transport, ILogger log) { if (message.RetryCount < ConfigurationContext.Current.MessageRetryLimit) { message.RetryCount++; log.InfoFormat("Message requested to be retried {0} - Retry Count {1}", message.ToString(), message.RetryCount); // Exponential backoff with a 90% - 110% jitter added to avoid synchronized backoffs on failures. var delayTime = TimeSpan.FromMilliseconds((Math.Pow(4, message.RetryCount) * 100) * (1.0 + (new Random().NextDouble() - 0.5) / 5)); message.RetryCount = message.RetryCount; // Convert to a delay result and process var delayResult = new DelayResult(DateTime.UtcNow.Add(delayTime)); delayResult.ProcessResult(message, transport, log); } else { // Out of retries, convert to a fail result var failResult = new FailResult(this.Message); failResult.ProcessResult(message, transport, log); } }
public void ProcessResult(RawMessage message, ITransport transport, ILogger log) { if (WillRetry(message.RetryCount)) { message.RetryCount++; log.InfoFormat("Message requested to be retried {0} - Retry Count {1}", message.ToString(), message.RetryCount); // Exponential backoff with a 90% - 110% jitter added to avoid synchronized backoffs on failures. var delayTime = TimeSpan.FromMilliseconds((Math.Pow(4, message.RetryCount) * 100) * (1.0 + (new Random().NextDouble() - 0.5) / 5)); message.RetryCount = message.RetryCount; // Convert to a delay result and process var delayResult = new DelayResult(DateTime.UtcNow.Add(delayTime)); delayResult.ProcessResult(message, transport, log); } else { // Out of retries, convert to a fail result var failResult = new FailResult(this.Message); failResult.ProcessResult(message, transport, log); } }