public static void Error( this ILog log, EnvelopedMessage context, string message, Exception exception = null) { var process = context.RoutingKey; log.Error(process, exception, message, context); }
public static void Warning( this ILog log, EnvelopedMessage context, object payload, MessageHeaders headers, string message, Exception exception = null) { var process = context.RoutingKey; log.Warning(process, message, exception, new { Headers = headers, Message = payload }); }
private async Task ProcessMessageAsync( IMessageSubscription subscription, EnvelopedMessage envelopedMessage, object payload, MessageHeaders headers) { var publisher = _repliesPublisher?.Invoke(headers.CorrelationId) ?? ProhibitedRepliesMessagePublisher.Instance; var handlingContext = new MessageHandlingContext ( envelopedMessage.Exchange, envelopedMessage.RetryCount, envelopedMessage.RoutingKey ); var result = await subscription.InvokeHandlerAsync(_serviceProvider, payload, headers, handlingContext, publisher); if (result == null) { throw new InvalidOperationException("Result should be not null"); } switch (result) { case MessageHandlingResult.SuccessResult _: case MessageHandlingResult.NonTransientFailureResult _: CurrentMessage.Ack(); break; case MessageHandlingResult.TransientFailureResult tfr: _retryManager.ScheduleRetry(CurrentMessage, tfr.RetryAfter ?? _defaultRetryTimeout); break; default: throw new NotSupportedException($"Unexpected message handling result [{result.GetType().Name}]."); } }