Search code examples
elsa-workflows

Workflow Elsa ParallelForEach blocking activity


I have a blocking activity after a parallel foreach which is waiting for an input to be restarted, on the other hand the column [WorkflowInstances].[Data] there is only the last activity blocked and not all the activities blocked after the Paralleforeach, also DispatchWorkflowsAsync return only the last activity. any idea ?


Solution

  • There is a known limitation with Elsa 2 that prevents the ParallelForEach activity from being able to handle blocking activities.

    The ParallelForEach activity iterates over each item immediately, thereby scheduling multiple Iterate outcomes, which schedules each subsequent activity for execution.

    When a blocking activity is encountered, its ID and type is stored in the blocking activities collection in the workflow instance object.

    And therein lies the problem: the blocking activities collection is a hash set - which means that every time the blocking activity gets registered here, it overwrites the one from the previous iteration.

    To solve for this, the internal structure of the workflow instance needs to be changed such that it can store multiple scopes as described in this issue.