Prevent independent Microflows from concurrent running
I have 2 different microflows that clash with each other if run at the same time so to prevent this I have created a persistent entity to act as a flag. Microflow 1 creates and commits a record in this flag entity, then runs it's onw logic and when finished deletes the flag entity. When microflow 2 runs it checks for any records in the flag entity and if found it will exit and not run. However the check for the entity record never returns anything and thus microflow 2 continues and I get the clash I'm hoping to avoid. The 2 microflows are in separate modules and it makes no difference which module I have the flag entity in. I have tried commiting the entity record as I create it and as an explict commit step. Does anyone have any suggestions as to why this approach isn't working, or suggestions for alternate ways to check for Microflow 1 running when executing Microflow 2? Thanks, Simon.
Use the community commons to commit in seperate database transaction. Because since the first microflow did not finish yet the record is not seen by the other microflow. By using the commitInSeparateDatabaseTransaction the commit takes place in its own transaction and thus can be seen by the other microflow.
As the first step in the two microflows:
Get the flag, if not set, set it, commit object and call java-action endTransaction. this wil store it in the datbase.
if set: wait or exit.
Don't forget to reset the flag in all cases, add a custom error handler.
Chris de Gelder
Perhaps using a shared MF that calls these sub microflows could work. And then set the non concurrent running option on that main microflow.