Docs
Tenantry ProAPI reference

TenantryProRebusBuilderExtensions class

Namespace: Microsoft.Extensions.DependencyInjection · Package: Tenantry.Pro.Rebus · API reference

Extension methods for adding the Rebus integration on IProBuilder<TKey>.

public static class TenantryProRebusBuilderExtensions

Methods

AddRebusPropagation<TKey>(IProBuilder<TKey>, Action<TenantPropagationOptions>?)

Makes a message sent or published while a tenant is current carry the tenant in a header, and makes that tenant current while the message is handled: the handlers, and the scoped services they take, see it. Wire it into Rebus with o.UseTenantry(sp) in Rebus's options.

public static IProBuilder<TKey> AddRebusPropagation<TKey>(this IProBuilder<TKey> pro, Action<TenantPropagationOptions>? configure = null) where TKey : IEquatable<TKey>, IParsable<TKey>

Type parameters:

  • TKey: The tenant identifier type.

Parameters:

Returns: IProBuilder<TKey>: The same pro for chaining.

The application fails to start if Rebus's configuration never calls o.UseTenantry(sp), which would leave messages without their tenant. Calling this again adds configure to the same options.

builder.Services.AddTenantry<string>(tenant => tenant
    .UseStore<MyTenantStore>()
    .UsePro(pro => pro.AddRebusPropagation()));
builder.Services.AddRebus((configure, sp) => configure
    .Transport(t => t.UseRabbitMq(connectionString, "orders"))
    .Options(o => o.UseTenantry(sp)));

On this page