From f11b7d5a21e374471d660bc3b6a968bc03e8915c Mon Sep 17 00:00:00 2001 From: n84ck <43924278+n84ck@users.noreply.github.com> Date: Sat, 12 Jul 2025 18:40:52 +0200 Subject: [PATCH] Update BackgroundStimulusDispatcher.cs Include tenant headers during command dispatch. --- .../Services/BackgroundStimulusDispatcher.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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); + } +}