public async Task DispatchAsync(ExecuteWorkflowInstanceRequest request, CancellationToken cancellationToken = default) { var workflowInstance = await _workflowInstanceStore.FindByIdAsync(request.WorkflowInstanceId, cancellationToken); if (workflowInstance == null) { _logger.LogWarning("Cannot dispatch a workflow instance ID that does not exist"); return; } var workflowBlueprint = await _workflowRegistry.FindAsync(workflowInstance.DefinitionId, VersionOptions.SpecificVersion(workflowInstance.Version), workflowInstance.TenantId, cancellationToken); if (workflowBlueprint == null) { _logger.LogWarning("Workflow instance {WorkflowInstanceId} references workflow blueprint {WorkflowDefinitionId} with version {Version}, but could not be found", workflowInstance.Id, workflowInstance.DefinitionId, workflowInstance.Version); return; } var channel = _workflowChannelOptions.GetChannelOrDefault(workflowBlueprint.Channel); var queue = ServiceBusOptions.FormatChannelQueueName <ExecuteWorkflowInstanceRequest>(channel); await _commandSender.SendAsync(request, queue, cancellationToken : cancellationToken); }
public async Task DispatchAsync(ExecuteWorkflowDefinitionRequest request, CancellationToken cancellationToken = default) { var workflowBlueprint = await _workflowRegistry.FindAsync(request.WorkflowDefinitionId, VersionOptions.Published, request.TenantId, cancellationToken); if (workflowBlueprint == null) { _logger.LogWarning("No published version found for workflow blueprint {WorkflowDefinitionId}", request.WorkflowDefinitionId); return; } var channel = _workflowChannelOptions.GetChannelOrDefault(workflowBlueprint.Channel); var queue = ServiceBusOptions.FormatChannelQueueName <ExecuteWorkflowDefinitionRequest>(channel); EnqueueJob <WorkflowDefinitionJob>(x => x.ExecuteAsync(request, CancellationToken.None), queue); }