コード例 #1
0
    /// <summary>
    /// Allows to convey the message handling failure that occurred in a specific handler
    /// </summary>
    /// <param name="context">Message context</param>
    /// <param name="handlerType">Handler type identifier</param>
    /// <param name="exception">Optional: handler exception</param>
    public static void Nack(this IBaseConsumeContext context, string handlerType, Exception?exception)
    {
        context.HandlingResults.Add(EventHandlingResult.Failed(handlerType, exception));
        if (exception is not TaskCanceledException)
        {
            Log.MessageHandlingFailed(handlerType, context, exception);
        }

        if (Activity.Current != null && Activity.Current.Status != ActivityStatusCode.Error)
        {
            Activity.Current.SetActivityStatus(
                ActivityStatus.Error(exception, $"Error handling {context.MessageType}")
                );
        }
    }
コード例 #2
0
 /// <summary>
 /// Allows to convey the fact that the message was ignored by the handler
 /// </summary>
 /// <param name="context">Consume context</param>
 /// <param name="handlerType">Handler type identifier</param>
 public static void Ignore(this IBaseConsumeContext context, string handlerType)
 {
     context.HandlingResults.Add(EventHandlingResult.Ignored(handlerType));
     Log.MessageIgnored(handlerType, context);
 }
コード例 #3
0
 /// <summary>
 /// Allows to acknowledge the message by a specific handler, identified by a string
 /// </summary>
 /// <param name="context">Consume context</param>
 /// <param name="handlerType">Handler type identifier</param>
 public static void Ack(this IBaseConsumeContext context, string handlerType)
 {
     context.HandlingResults.Add(EventHandlingResult.Succeeded(handlerType));
     Log.MessageHandled(handlerType, context);
 }