Skip to content

Instantly share code, notes, and snippets.

@pardahlman
Last active January 25, 2017 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pardahlman/db0d7bb93d2540aa4a07bf7771929191 to your computer and use it in GitHub Desktop.
Save pardahlman/db0d7bb93d2540aa4a07bf7771929191 to your computer and use it in GitHub Desktop.
protected static Task SubscribeAsync<TMessage, TMessageContext>(Func<TMessage, TMessageContext, Task> asyncHandler)
{
return BusClient.SubscribeAsync<TMessage, TMessageContext>(async (message, context) =>
{
var customCtx = context as CustomContext;
using (LogContext.PushProperty("executionId", customCtx?.ExecutionId))
using (LogContext.PushProperty("origin", customCtx?.Origin))
using (LogContext.PushProperty("sessionId", customCtx?.SessionId))
{
await asyncHandler(message, context);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment