Tenantry ProAPI reference
TenantryRebusHeadersExtensions class
Namespace: Rebus.Bus · Package: Tenantry.Pro.Rebus · API reference
Extension methods for sending or publishing a message for a tenant other than the current one.
public static class TenantryRebusHeadersExtensionsMethods
WithTenant<TKey>(IDictionary<string, string>, TKey)
Adds tenantId to the headers a message is sent or published with, so it is handled as that tenant (pro.AddRebusPropagation()), whichever tenant is current, if any: for sending on a tenant's behalf from code that runs without one, such as a scheduled task or an administrator's request.
public static IDictionary<string, string> WithTenant<TKey>(this IDictionary<string, string> headers, TKey tenantId) where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters:
TKey: The tenant identifier type.
Parameters:
headersIDictionary<string, string>: The headers to send the message with, as passed toSend,PublishorDefer.tenantIdTKey: The tenant's id. The tenant is looked up when the message is handled.
Returns: IDictionary<string, string>: The same headers for chaining.
Exceptions:
ArgumentException:tenantIdis the key type's default value (Guid.Empty,0) or an empty string, which Tenantry reserves for "no tenant".
It sets the TenantPropagation.HeaderName header, which Tenantry's outgoing step then leaves in place.
await bus.Send(new InvoiceDue(invoiceId), new Dictionary<string, string>().WithTenant(tenantId));