diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs index e730be327..0209dffb1 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using System; using Grpc.Core; using Serilog; +using Polly; namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services { @@ -27,7 +28,11 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services try { - return await func(httpClient); + return await Policy + .Handle(ex => true) + .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress,e.Message)) + .ExecuteAsync(() => func(httpClient)) + ; } catch (RpcException e) { @@ -59,7 +64,11 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services try { - await func(httpClient); + await Policy + .Handle(ex => true) + .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress, e.Message)) + .ExecuteAsync(() => func(httpClient)) + ; } catch (RpcException e) { diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs index 6400c9797..d69a30f88 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using System; using Grpc.Core; using Serilog; +using Polly; namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services { @@ -27,7 +28,11 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services try { - return await func(httpClient); + return await Policy + .Handle(ex => true) + .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress, e.Message)) + .ExecuteAsync(() => func(httpClient)) + ; } catch (RpcException e) { @@ -59,7 +64,11 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services try { - await func(httpClient); + await Policy + .Handle(ex => true) + .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress, e.Message)) + .ExecuteAsync(() => func(httpClient)) + ; } catch (RpcException e) {