|
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using Polly; |
|
|
|
using Polly.Contrib.WaitAndRetry; |
|
|
|
using Polly.Retry; |
|
|
|
using RabbitMQ.Client; |
|
|
|
using RabbitMQ.Client.Events; |
|
|
@ -73,11 +74,13 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ |
|
|
|
_persistentConnection.TryConnect(); |
|
|
|
} |
|
|
|
|
|
|
|
var delay = Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(2), retryCount: _retryCount); |
|
|
|
|
|
|
|
var policy = RetryPolicy.Handle<BrokerUnreachableException>() |
|
|
|
.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; |
|
|
|