Skip to content

Instantly share code, notes, and snippets.

@ramonsmits
Created March 22, 2018 13:51
Show Gist options
  • Select an option

  • Save ramonsmits/b274545e3f6891ebd8a5a5c8a936cf02 to your computer and use it in GitHub Desktop.

Select an option

Save ramonsmits/b274545e3f6891ebd8a5a5c8a936cf02 to your computer and use it in GitHub Desktop.
NServiceBus add StackTrace information to outgoing message
// Via send options.
var sendOptions = new SendOptions();
sendOptions.SetHeader("StackTrace", System.Environment.StackTrace);
await context.Send(myMessage, sendOptions).ConfigureAwait(false);
// Via outgoing message mutator, requires registering the mutator via the endpoint configuration.
class AddStackTraceMutator : IMutateOutgoingTransportMessages
{
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context)
{
context.OutgoingHeaders["StackTrace"] = System.Environment.StackTrace;
return Task.CompletedTask;
}
}
endpointConfiguration.RegisterMessageMutator(new AddStackTraceMutator ());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment