title: Get Tenant Id from RabbitMq Message for Db Connection
body: <p>I have a microservice architecture with ASP.Net Core applications and RabbitMq as the event bus between the microservices.<br>
  I also want to support multi tenancy.<br>
  So I have following dependency injection service defined in the <code>Startup.cs</code> to open a connection to the Database on every request based on the user's tenant id.</p>
  
  <pre><code>services.AddScoped&lt;IDocumentSession&gt;(ds =&gt;
              {
                  var store = ds.GetRequiredService&lt;IDocumentStore&gt;();
                  var httpContextAccessor = ds.GetRequiredService&lt;IHttpContextAccessor&gt;();
                  var tenant = httpContextAccessor?.HttpContext?.User?.Claims.FirstOrDefault(c =&gt; c.Type == "tid")?.Value;
                  return tenant != null ? store.OpenSession(tenant) : store.OpenSession();
              });
  </code></pre>
  
  <p>The problem is when the service processes an event bus message (like UserUpdatedEvent).<br>
  In that case when it tries to open the Db connection, it obviously does not have the user information from the http context.</p>
  
  <p>How do I send/access the tenant id of the respective user when injecting the scoped service and processing an event with RabbitMq?</p>
  
  <p>Or rephrasing my question:
  Is there any way to access the RabbitMQ message (and for example its headers) when the dependency injection code is executed?</p>