Update BackgroundStimulusDispatcher.cs
Include tenant headers during command dispatch.
This commit is contained in:
parent
fd5579e551
commit
f11b7d5a21
|
|
@ -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;
|
|||
/// <summary>
|
||||
/// A simple implementation that queues the specified request for delivering stimuli on a non-durable background worker.
|
||||
/// </summary>
|
||||
public class BackgroundStimulusDispatcher(ICommandSender commandSender) : IStimulusDispatcher
|
||||
public class BackgroundStimulusDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IStimulusDispatcher
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public async Task<DispatchStimulusResponse> 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;
|
||||
}
|
||||
}
|
||||
|
||||
private IDictionary<object, object> CreateHeaders()
|
||||
{
|
||||
return TenantHeaders.CreateHeaders(tenantAccessor.Tenant?.Id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue