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;
///
/// A simple implementation that queues the specified request for delivering stimuli on a non-durable background worker.
///
public class BackgroundStimulusDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IStimulusDispatcher
{
///
public async Task SendAsync(DispatchStimulusRequest request, CancellationToken cancellationToken = default)
{
var command = new DispatchStimulusCommand(request);
// Background commands run independently of caller's lifecycle.
await commandSender.SendAsync(command, CommandStrategy.Background, CreateHeaders(), CancellationToken.None);
return DispatchStimulusResponse.Empty;
}
private IDictionary