diff --git a/src/Web/WebMVC/Controllers/OrderController.cs b/src/Web/WebMVC/Controllers/OrderController.cs
index 3d9317ae6..104ae9f9b 100644
--- a/src/Web/WebMVC/Controllers/OrderController.cs
+++ b/src/Web/WebMVC/Controllers/OrderController.cs
@@ -54,7 +54,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
}
catch(BrokenCircuitException ex)
{
- ModelState.AddModelError("Error", "Not possible to create a new order, please try later on");
+ ModelState.AddModelError("Error", "It was not possible to create a new order, please try later on");
}
return View(model);
}
diff --git a/src/Web/WebMVC/Services/Utilities/ResilientHttpClient.cs b/src/Web/WebMVC/Services/Utilities/ResilientHttpClient.cs
index 833db61c0..4ff4b1151 100644
--- a/src/Web/WebMVC/Services/Utilities/ResilientHttpClient.cs
+++ b/src/Web/WebMVC/Services/Utilities/ResilientHttpClient.cs
@@ -12,9 +12,7 @@ namespace WebMVC.Services.Utilities
{
///
/// HttpClient wrapper that integrates Retry and Circuit
- /// breaker policies when calling to Api services.
- /// Currently is ONLY implemented for the ASP MVC
- /// and Xamarin App
+ /// breaker policies when invoking HTTP services.
///
public class ResilientHttpClient : IHttpClient
{
@@ -34,42 +32,44 @@ namespace WebMVC.Services.Utilities
);
}
- private Policy CreateCircuitBreakerPolicy() =>
- Policy.Handle()
- .CircuitBreakerAsync(
- // number of exceptions before breaking circuit
- 5,
- // time circuit opened before retry
- TimeSpan.FromMinutes(1),
- (exception, duration) =>
- {
- // on circuit opened
- _logger.LogTrace("Circuit breaker opened");
- },
- () =>
- {
- // on circuit closed
- _logger.LogTrace("Circuit breaker reset");
- }
- );
-
private Policy CreateRetryPolicy() =>
Policy.Handle()
.WaitAndRetryAsync(
// number of retries
- 5,
+ 6,
// exponential backofff
- retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)),
+ retryAttempt => TimeSpan.FromSeconds(Math.Pow(1, retryAttempt)),
// on retry
(exception, timeSpan, retryCount, context) =>
{
- _logger.LogTrace($"Retry {retryCount} " +
+ var msg = $"Retry {retryCount} implemented with Polly's RetryPolicy " +
$"of {context.PolicyKey} " +
$"at {context.ExecutionKey}, " +
- $"due to: {exception}.");
+ $"due to: {exception}.";
+ _logger.LogWarning(msg);
+ _logger.LogDebug(msg);
}
);
+ private Policy CreateCircuitBreakerPolicy() =>
+ Policy.Handle()
+ .CircuitBreakerAsync(
+ // number of exceptions before breaking circuit
+ 5,
+ // time circuit opened before retry
+ TimeSpan.FromMinutes(1),
+ (exception, duration) =>
+ {
+ // on circuit opened
+ _logger.LogTrace("Circuit breaker opened");
+ },
+ () =>
+ {
+ // on circuit closed
+ _logger.LogTrace("Circuit breaker reset");
+ }
+ );
+
public Task GetStringAsync(string uri) =>
HttpInvoker(() =>
_client.GetStringAsync(uri));