mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-05-04 11:58:46 +08:00
fix: Fix EfTxBehavior for save persist-message
This commit is contained in:
parent
7e9cea74f6
commit
cc710292a3
@ -195,6 +195,9 @@ dotnet_separate_import_directive_groups = false
|
|||||||
dotnet_style_namespace_match_folder = false
|
dotnet_style_namespace_match_folder = false
|
||||||
dotnet_diagnostic.IDE0130.severity = none
|
dotnet_diagnostic.IDE0130.severity = none
|
||||||
|
|
||||||
|
[*.{cs,vb}]
|
||||||
|
dotnet_diagnostic.CA1305.severity = none
|
||||||
|
|
||||||
# C# formatting rules
|
# C# formatting rules
|
||||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
|
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
|
||||||
[*.{cs,csx,cake}]
|
[*.{cs,csx,cake}]
|
||||||
|
|||||||
@ -79,12 +79,10 @@ public class EfTxBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TRe
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Save data to database with some retry policy in distributed transaction
|
// Save data to database with some retry policy in distributed transaction
|
||||||
await _dbContextBase.RetryOnFailure(async () =>
|
await _persistMessageDbContext.RetryOnFailure(async () =>
|
||||||
{
|
{
|
||||||
await _dbContextBase.SaveChangesAsync(cancellationToken);
|
|
||||||
});
|
|
||||||
|
|
||||||
await _persistMessageDbContext.SaveChangesAsync(cancellationToken);
|
await _persistMessageDbContext.SaveChangesAsync(cancellationToken);
|
||||||
|
});
|
||||||
|
|
||||||
scope.Complete();
|
scope.Complete();
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
namespace BuildingBlocks.Polly;
|
namespace BuildingBlocks.Polly;
|
||||||
|
|
||||||
using global::Polly;
|
using global::Polly;
|
||||||
|
using Serilog;
|
||||||
using Exception = System.Exception;
|
using Exception = System.Exception;
|
||||||
|
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
@ -9,10 +10,10 @@ public static class Extensions
|
|||||||
{
|
{
|
||||||
var retryPolicy = Policy
|
var retryPolicy = Policy
|
||||||
.Handle<Exception>()
|
.Handle<Exception>()
|
||||||
.Retry(retryCount, (exception, retryAttempt) =>
|
.Retry(retryCount, (exception, retryAttempt, context) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Retry attempt: {retryAttempt}");
|
Log.Information($"Retry attempt: {retryAttempt}");
|
||||||
Console.WriteLine($"Exception: {exception.Message}");
|
Log.Error($"Exception: {exception.Message}");
|
||||||
});
|
});
|
||||||
|
|
||||||
return retryPolicy.Execute(action);
|
return retryPolicy.Execute(action);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user