Compare commits
1 Commits
dev
...
feature/ad
Author | SHA1 | Date | |
---|---|---|---|
|
6db9917621 |
@ -17,6 +17,7 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
|
||||||
|
@ -21,6 +21,7 @@ using HealthChecks.UI.Client;
|
|||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Devspaces.Support;
|
using Devspaces.Support;
|
||||||
|
using Polly.Contrib.WaitAndRetry;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
||||||
{
|
{
|
||||||
@ -208,10 +209,12 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
|||||||
|
|
||||||
private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
||||||
{
|
{
|
||||||
|
var delay = Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(2), retryCount: 6);
|
||||||
|
|
||||||
return HttpPolicyExtensions
|
return HttpPolicyExtensions
|
||||||
.HandleTransientHttpError()
|
.HandleTransientHttpError()
|
||||||
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
|
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||||
.WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
|
.WaitAndRetryAsync(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IAsyncPolicy<HttpResponseMessage> GetCircuitBreakerPolicy()
|
private static IAsyncPolicy<HttpResponseMessage> GetCircuitBreakerPolicy()
|
||||||
|
@ -22,6 +22,7 @@ using HealthChecks.UI.Client;
|
|||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Devspaces.Support;
|
using Devspaces.Support;
|
||||||
|
using Polly.Contrib.WaitAndRetry;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
||||||
{
|
{
|
||||||
@ -207,10 +208,12 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
|||||||
|
|
||||||
static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
||||||
{
|
{
|
||||||
|
var delay = Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(2), retryCount: 6);
|
||||||
|
|
||||||
return HttpPolicyExtensions
|
return HttpPolicyExtensions
|
||||||
.HandleTransientHttpError()
|
.HandleTransientHttpError()
|
||||||
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
|
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||||
.WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
|
.WaitAndRetryAsync(delay);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.4" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Polly;
|
using Polly;
|
||||||
|
using Polly.Contrib.WaitAndRetry;
|
||||||
using Polly.Retry;
|
using Polly.Retry;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using RabbitMQ.Client.Events;
|
using RabbitMQ.Client.Events;
|
||||||
@ -68,11 +69,13 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
|
|||||||
|
|
||||||
lock (sync_root)
|
lock (sync_root)
|
||||||
{
|
{
|
||||||
|
var delay = Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(2), retryCount: _retryCount);
|
||||||
|
|
||||||
var policy = RetryPolicy.Handle<SocketException>()
|
var policy = RetryPolicy.Handle<SocketException>()
|
||||||
.Or<BrokerUnreachableException>()
|
.Or<BrokerUnreachableException>()
|
||||||
.WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
|
.WaitAndRetry(delay, (ex, time) =>
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "RabbitMQ Client could not connect after {TimeOut}s ({ExceptionMessage})", $"{time.TotalSeconds:n1}", ex.Message);
|
_logger.LogWarning(ex, "RabbitMQ Client could not connect after {TimeOut}s ({ExceptionMessage})", $"{time.TotalSeconds:n3}", ex.Message);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Polly;
|
using Polly;
|
||||||
|
using Polly.Contrib.WaitAndRetry;
|
||||||
using Polly.Retry;
|
using Polly.Retry;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using RabbitMQ.Client.Events;
|
using RabbitMQ.Client.Events;
|
||||||
@ -73,11 +74,13 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
|
|||||||
_persistentConnection.TryConnect();
|
_persistentConnection.TryConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var delay = Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(2), retryCount: _retryCount);
|
||||||
|
|
||||||
var policy = RetryPolicy.Handle<BrokerUnreachableException>()
|
var policy = RetryPolicy.Handle<BrokerUnreachableException>()
|
||||||
.Or<SocketException>()
|
.Or<SocketException>()
|
||||||
.WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
|
.WaitAndRetry(delay, (ex, time) =>
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "Could not publish event: {EventId} after {Timeout}s ({ExceptionMessage})", @event.Id, $"{time.TotalSeconds:n1}", ex.Message);
|
_logger.LogWarning(ex, "Could not publish event: {EventId} after {Timeout}s ({ExceptionMessage})", @event.Id, $"{time.TotalSeconds:n3}", ex.Message);
|
||||||
});
|
});
|
||||||
|
|
||||||
var eventName = @event.GetType().Name;
|
var eventName = @event.GetType().Name;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
<PackageReference Include="Polly" Version="6.0.1" />
|
<PackageReference Include="Polly" Version="6.0.1" />
|
||||||
|
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.0.0" />
|
||||||
<PackageReference Include="RabbitMQ.Client" Version="5.0.1" />
|
<PackageReference Include="RabbitMQ.Client" Version="5.0.1" />
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -17,6 +17,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Polly;
|
using Polly;
|
||||||
|
using Polly.Contrib.WaitAndRetry;
|
||||||
using Polly.Extensions.Http;
|
using Polly.Extensions.Http;
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using System;
|
using System;
|
||||||
@ -274,10 +275,12 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
|
|
||||||
static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
||||||
{
|
{
|
||||||
|
var delay = Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(2), retryCount: 6);
|
||||||
|
|
||||||
return HttpPolicyExtensions
|
return HttpPolicyExtensions
|
||||||
.HandleTransientHttpError()
|
.HandleTransientHttpError()
|
||||||
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
|
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||||
.WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
|
.WaitAndRetryAsync(delay);
|
||||||
|
|
||||||
}
|
}
|
||||||
static IAsyncPolicy<HttpResponseMessage> GetCircuitBreakerPolicy()
|
static IAsyncPolicy<HttpResponseMessage> GetCircuitBreakerPolicy()
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Fabric.MSBuild" Version="1.6.7" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Fabric.MSBuild" Version="1.6.7" />
|
||||||
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.9.20" />
|
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.9.20" />
|
||||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" />
|
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" />
|
||||||
|
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user