Browse Source

Optimize message queue error message prompt.

master
Savorboard 7 years ago
parent
commit
8e8155db1f
2 changed files with 13 additions and 1 deletions
  1. +1
    -1
      src/DotNetCore.CAP/IConsumerHandler.Default.cs
  2. +12
    -0
      src/DotNetCore.CAP/LoggerExtensions.cs

+ 1
- 1
src/DotNetCore.CAP/IConsumerHandler.Default.cs View File

@@ -105,7 +105,7 @@ namespace DotNetCore.CAP
Pulse();
};

client.OnError += (sender, reason) => { _logger.LogError(reason); };
client.OnError += (sender, reason) => { _logger.MessageQueueError(reason); };
}

private static void StoreMessage(IServiceScope serviceScope, MessageContext messageContext)


+ 12
- 0
src/DotNetCore.CAP/LoggerExtensions.cs View File

@@ -22,6 +22,8 @@ namespace DotNetCore.CAP
private static readonly Action<ILogger, int, Exception> _jobRetrying;
private static readonly Action<ILogger, string, Exception> _exceptionOccuredWhileExecutingJob;

private static readonly Action<ILogger, string, Exception> _messageQueueError;

static LoggerExtensions()
{
_serverStarting = LoggerMessage.Define<int, int>(
@@ -95,6 +97,11 @@ namespace DotNetCore.CAP
6,
"An exception occured while trying to execute a message: '{MessageId}'. " +
"Requeuing for another retry.");

_messageQueueError = LoggerMessage.Define<string>(
LogLevel.Error,
7,
"The MessageQueue Client fires an internal error:'{error}'.");
}

public static void JobFailed(this ILogger logger, Exception ex)
@@ -167,5 +174,10 @@ namespace DotNetCore.CAP
{
_modelBinderFormattingException(logger, methodName, parameterName, content, ex);
}

public static void MessageQueueError(this ILogger logger, string error)
{
_messageQueueError(logger, error, null);
}
}
}

Loading…
Cancel
Save