/// <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}") ); } }
/// <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); }
/// <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); }