public override async Task Invoke(ITransportReceiveContext context, Func <Task> next) { try { await next() .ConfigureAwait(false); } catch (Exception ex) { if (!EnsureNotReported(context)) { return; } var ctx = new NServiceBusContext(this, ex) { RawBody = context.Message.Body, MessageHeaders = context.Message.Headers, MessageId = context.Message.MessageId }; ctx.AddHighlightedProperty("MessageHeaders", "MessageType"); ctx.AddHighlightedCollection("MessageBody"); ctx.AddTag("serialization"); ctx.AddTag("nservicebus"); _processor.Process(ctx); throw; } }
private void ReportSlowMessageHandler(IInvokeHandlerContext context, TimeSpan elapsed) { var ex = new SlowMessageHandlerException(context.MessageHandler.HandlerType.Name, elapsed); var ctx = new NServiceBusContext(this, ex) { HandlerInstance = context.MessageHandler.Instance, HandlerType = context.MessageHandler.HandlerType, Body = context.MessageBeingHandled, Metadata = context.MessageMetadata, MessageType = context.MessageMetadata.MessageType, IsHandled = !context.HandlerInvocationAborted, MessageHeaders = context.MessageHeaders, MessageId = context.MessageId, ReplyToAddress = context.ReplyToAddress }; ctx.AddHighlightedProperty("MessageHandler", "Type"); ctx.AddHighlightedCollection("MessageBody"); ctx.AddTag("performance"); ctx.AddTag("nservicebus"); Err.Report(ctx); }
public override async Task Invoke(IIncomingLogicalMessageContext context, Func <Task> next) { try { var sw = Stopwatch.StartNew(); await next() .ConfigureAwait(false); sw.Stop(); } catch (Exception ex) { if (!EnsureNotReported(context)) { return; } var ctx = new NServiceBusContext(this, ex) { Body = context.Message.Instance, Metadata = context.Message.Metadata, MessageType = context.Message.MessageType, IsHandled = context.MessageHandled, MessageHeaders = context.MessageHeaders, MessageId = context.MessageId, ReplyToAddress = context.ReplyToAddress }; ctx.AddHighlightedProperty("MessageHandler", "Type"); ctx.AddHighlightedCollection("MessageBody"); ctx.AddTag("nservicebus"); Err.Report(ctx); throw; } }