How to run multiple sub-microflows asynchronously and show page only after all complete?

0
Hi all, I have a button that triggers a microflow. Inside that main microflow, I’m calling four sub-microflows followed by a Show Page activity at the end. Each of these four sub-microflows is independent — they don’t depend on each other’s outputs. Currently, they execute sequentially, which increases the total time before the page is displayed. What I’d like to achieve is: All four sub-microflows should run asynchronously (in parallel). Once all four are completed, then the page should be shown. I explored using Task Queues, but since tasks are executed after the microflow’s end event, it doesn’t help in this scenario — I need those four to be completed before showing the page. Has anyone handled a similar scenario or found a good approach to run parallel flows and wait for all to finish before proceeding?Any ideas or best practices would be greatly appreciated.   Thanks in advance, Deepalakshmi
asked
3 answers
0

You can run your background microflow in a task queue

answered
0

I was going to post about this exact same question. 

 

The discovery that the Task Queues commit after the primary microflow means that the polling sub microflow that I set up to track the process sits in an infinite loop due to the fact that the sub microflows are not updating the entity.

 

You would think that the sub microflows in the task queue would execute their commits outside of the main microflows but seems that this is not the case.

answered
0

running tasks asynchronously is creating a new thread(s), this makes it impossible to give direct feedback to the original microflow.

 

What is possible, but a tricky solution is to 'flip a switch' for every task that is completed in the database. Create for every task an object before starting the flow, and set the boolean to complete at the end of the task. In the main flow, loop until all the objects for the tasks are completed. This creates the risk of an endless loop when one of the tasks fail. so restrict the time the flow loops is my advice.

 

Another solution is to work with something like a websocket to provide feedback directly to the page when the flows are completed, since the follow-up action is opening a page, a websocket can handle that as well.

answered