Resolve #728 - Fix ActivityExecuted persistence

The PersistWorkflow service will now handle ActivityExecuted
persistence behaviour, presumably as-intended.
This commit is contained in:
Craig Fowler 2021-03-09 20:09:36 +00:00
parent 8751bead5a
commit 7f5a6228cf

View file

@ -15,7 +15,8 @@ namespace Elsa.Handlers
INotificationHandler<WorkflowExecutionPassCompleted>,
INotificationHandler<WorkflowExecutionBurstStarting>,
INotificationHandler<WorkflowExecutionBurstCompleted>,
INotificationHandler<WorkflowExecutionFinished>
INotificationHandler<WorkflowExecutionFinished>,
INotificationHandler<ActivityExecuted>
{
private readonly IWorkflowInstanceStore _workflowInstanceStore;
private readonly ILogger _logger;
@ -94,6 +95,16 @@ namespace Elsa.Handlers
}
}
public async Task Handle(ActivityExecuted notification, CancellationToken cancellationToken)
{
_logger.LogTrace("Received notification {notification}", notification);
var behavior = notification.WorkflowExecutionContext.WorkflowBlueprint.PersistenceBehavior;
if (behavior == WorkflowPersistenceBehavior.ActivityExecuted)
await SaveWorkflowAsync(notification.WorkflowExecutionContext, cancellationToken);
}
private async ValueTask SaveWorkflowAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken)
{
_logger.LogTrace("Persisting workflow instance {instanceId}", workflowExecutionContext.WorkflowInstance.Id);