From bc70beff12315bd8cb2d983c583e97a0c417aa8b Mon Sep 17 00:00:00 2001
From: Sverre Winkelmans <69142682+Sverre-W@users.noreply.github.com>
Date: Fri, 16 Jan 2026 15:07:06 +0700
Subject: [PATCH] Add tenant headers support to
BackgroundWorkflowCancellationDispatcher (#7040)
* Add tenant headers support to BackgroundWorkflowCancellationDispatcher
* Fix 'CreateHeaders' call
---
...ackgroundWorkflowCancellationDispatcher.cs | 47 +++++++++++--------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/src/modules/Elsa.Workflows.Runtime/Services/BackgroundWorkflowCancellationDispatcher.cs b/src/modules/Elsa.Workflows.Runtime/Services/BackgroundWorkflowCancellationDispatcher.cs
index a07d3823f..cb2f71782 100644
--- a/src/modules/Elsa.Workflows.Runtime/Services/BackgroundWorkflowCancellationDispatcher.cs
+++ b/src/modules/Elsa.Workflows.Runtime/Services/BackgroundWorkflowCancellationDispatcher.cs
@@ -1,21 +1,28 @@
-using Elsa.Mediator;
-using Elsa.Mediator.Contracts;
-using Elsa.Workflows.Runtime.Commands;
-using Elsa.Workflows.Runtime.Requests;
-using Elsa.Workflows.Runtime.Responses;
-
-namespace Elsa.Workflows.Runtime;
-
-///
-/// Dispatches workflow cancellation requests to a local background worker.
-///
-public class BackgroundWorkflowCancellationDispatcher(ICommandSender commandSender) : IWorkflowCancellationDispatcher
-{
- ///
- public async Task DispatchAsync(DispatchCancelWorkflowRequest request, CancellationToken cancellationToken = default)
- {
- var command = new CancelWorkflowsCommand(request);
- await commandSender.SendAsync(command, CommandStrategy.Background, cancellationToken);
- return new DispatchCancelWorkflowsResponse();
- }
+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;
+
+namespace Elsa.Workflows.Runtime;
+
+///
+/// Dispatches workflow cancellation requests to a local background worker.
+///
+public class BackgroundWorkflowCancellationDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IWorkflowCancellationDispatcher
+{
+ ///
+ public async Task DispatchAsync(DispatchCancelWorkflowRequest request, CancellationToken cancellationToken = default)
+ {
+ var command = new CancelWorkflowsCommand(request);
+ await commandSender.SendAsync(command, CommandStrategy.Background, CreateHeaders(), cancellationToken);
+ return new DispatchCancelWorkflowsResponse();
+ }
+
+ private IDictionary