Workflow commands vs steps


I understand that a value or event source entity executes commands serially. How does the Workflow execute commands when asynchronous steps are running?

Say there are 3 steps: A (take 5 secs then transitions to B), B (do stuff then pause) and C (do stuff then end). And 2 commands : Start (transitions to A) and Complete (transitions to C). The second command, Complete, can be received anytime between step A’s call and step B’s pause.

Assuming Complete is received before B’s pause:
a) Will the workflow wait until the workflow hits “.pause” and then execute the Complete command?
b) Will it abruptly cancel step B and transition to step C?
c) Something else?

Thank you

Hi @glop.postbox.0u

in the current Workflows implementation, you should apply a custom logic to check if you can process a given command, like here. In your case you should encode the information about the processing progress in your Workflow state object, so that the command Completed will be rejected until B is completed and paused.

Without such a check, the Workflow will transition to C while B step keeps running, which could break the workflow logic.

We are planing to improve this and automatically reject any the command if a step is in progress. Although, tracking the workflow progress in the state is pretty natural, so the only additional job for now is to remember to validate the command.

1 Like