Run workflows directly from Azure queue

This commit is contained in:
Sipke Schoorstra 2021-01-10 17:08:56 +01:00
parent 49d4e5bb36
commit 67cfbb6c1a

View file

@ -38,10 +38,10 @@ namespace Elsa.Activities.AzureServiceBus.Services
private async Task TriggerWorkflowsAsync(Message message, CancellationToken cancellationToken)
{
_logger.LogDebug("Triggering workflow {MessageId}", message.MessageId);
using var scope = _serviceProvider.CreateScope();
var workflowQueue = scope.ServiceProvider.GetRequiredService<IWorkflowQueue>();
await workflowQueue.EnqueueWorkflowsAsync<MessageReceivedTrigger>(
var workflowRunner = scope.ServiceProvider.GetRequiredService<IWorkflowRunner>();
await workflowRunner.TriggerWorkflowsAsync<MessageReceivedTrigger>(
x => x.QueueName == _messageReceiver.Path && (string.Equals(x.CorrelationId, message.CorrelationId)),
message, message.CorrelationId,
cancellationToken: cancellationToken);