diff --git a/src/modules/Elsa.Workflows.Runtime/Services/BackgroundStimulusDispatcher.cs b/src/modules/Elsa.Workflows.Runtime/Services/BackgroundStimulusDispatcher.cs index 58fad4747..614f63a8d 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/BackgroundStimulusDispatcher.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/BackgroundStimulusDispatcher.cs @@ -1,5 +1,7 @@ +using Elsa.Common.Multitenancy; using Elsa.Mediator; using Elsa.Mediator.Contracts; +using Elsa.Tenants.Mediator; using Elsa.Workflows.Runtime.Commands; using Elsa.Workflows.Runtime.Requests; using Elsa.Workflows.Runtime.Responses; @@ -9,13 +11,18 @@ namespace Elsa.Workflows.Runtime; /// /// A simple implementation that queues the specified request for delivering stimuli on a non-durable background worker. /// -public class BackgroundStimulusDispatcher(ICommandSender commandSender) : IStimulusDispatcher +public class BackgroundStimulusDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IStimulusDispatcher { /// public async Task SendAsync(DispatchStimulusRequest request, CancellationToken cancellationToken = default) { var command = new DispatchStimulusCommand(request); - await commandSender.SendAsync(command, CommandStrategy.Background, cancellationToken); + await commandSender.SendAsync(command, CommandStrategy.Background, CreateHeaders(), cancellationToken); return DispatchStimulusResponse.Empty; } -} \ No newline at end of file + + private IDictionary CreateHeaders() + { + return TenantHeaders.CreateHeaders(tenantAccessor.Tenant?.Id); + } +}