elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

Job fire and forget is not working

Open johnwc opened this issue 2 years ago • 8 comments

I created a master workflow that has several other workflows chained one after another. Each start workflow activity is set to Fire and forget. But, the workflows only start after the previous one in the chain completes.

johnwc avatar Jun 26 '22 00:06 johnwc

The "fire and forget" term is misleading in this context. What the Run Workflow activity actually does is execute a workflow and wait for it to either complete or get suspended. If the child workflow gets suspended, then the "fire and forget" setting will cause the main workflow to continue to its next activity. The "blocking" mode on the other hand will suspend itself until the child workflow completes.

What you're after is a true fire and forget behavior, where the main workflow dispatches the child workflow, not execute it. We should probably add a new mode called e.g. "TRUE fire and forget" (maybe using a better name 😉).

The following would be a proper list of modes:

  • Blocking (waits for the child workflow to complete)
  • Start (starts the child workflow until it either completes or gets suspended - right now this mode is called "fire and forget")
  • Fire and forget (dispatches the child workflow and carries on to the next activity)

sfmskywalker avatar Jun 27 '22 12:06 sfmskywalker

After much trial and error, I ended up stumbling upon adding a short 10 second timer to the workflows we are starting so that they suspend and allow the parent to continue. So this will suffice for now until there is an official solution.

I think the Start need to be so that it Starts the workflow but waits for it to complete none blocking. To me Fire and Forget tells me that the workflow is started and we don't care the outcome at all and will not wait for anything, we are just initiating it and moving on.

johnwc avatar Jun 27 '22 16:06 johnwc

Would be nice to get a real fire and forget - which is also capable to spread the instanced distributed across all workers =) .

Adrian-Grimm avatar Nov 17 '22 17:11 Adrian-Grimm

Exactly, that’s what I proposed in my previous comment with the Fire and Forget mode. When using the dispatcher, it achieves exactly that: the child workflow execution instruction gets sent to a queue, which then gets picked up by any node in the cluster :)

sfmskywalker avatar Nov 17 '22 20:11 sfmskywalker

@sfmskywalker can you let us know when this new functionality has been added to the engine?

johnwc avatar Nov 26 '22 19:11 johnwc

@johnwc A pull of us got merged: https://github.com/elsa-workflows/elsa-core/pull/3455 which solved https://github.com/elsa-workflows/elsa-core/issues/3451 with this we have such a feature in the next release.

Adrian-Grimm avatar Dec 05 '22 12:12 Adrian-Grimm