private void SetHeaders(SendContext context) { var appContext = _appContextProvider.Get(); var tenant = appContext.Tenant; if (!string.IsNullOrWhiteSpace(tenant) && !context.Headers.TryGetHeader(Headers.Tenant, out _)) { context.SetTenant(tenant); } var userId = appContext.UserId; if (!string.IsNullOrWhiteSpace(userId) && !context.Headers.TryGetHeader(Headers.UserId, out _)) { context.SetUserId(userId); } var correlationId = appContext.CorrelationId; if (correlationId != Guid.Empty && !context.Headers.TryGetHeader(Headers.CorrelationId, out _)) { context.SetCorrelationId(correlationId); } }
public Task Send(ConsumeContext <TMessage> context, IPipe <ConsumeContext <TMessage> > next) { var appContext = _appContextProvider.Get(); using var scope = _logger.BeginScope( "Tenant: {AppContext.Tenant}, CorrelationID: {AppContext.CorrelationId}", appContext.Tenant, appContext.CorrelationId); return(next.Send(context)); }
public Task Consume(ConsumeContext <Test2> context) { Console.WriteLine(_provider.Get().Tenant); return(Task.CompletedTask); }
public async Task Consume(ConsumeContext <Test1> context) { Console.WriteLine($"Test1 : {_provider.Get().Tenant}"); await context.Publish(new Test2()); }