I need to execute a (sub-)microflow in a transaction that is separate from the 'parent' context. The reason for this is a concurrency problem. I need to be certain that a Mendix object commit is also committed to the database before continuing the parent microflow. My question is this: Does the 'session.createContext()' Java method call create a new context including a new transaction? I am planning on using the 'executeMicroflowAsUser' Java action from the CommunityCommons module for this purpose. If not, how else can I ensure that a separate transaction is started and committed within a parent microflow?
Jonathan van Alteren
What exactly is your use-case? The solution will depend on that. You can start and end transactions with context.startTransaction and context.endTransaction but when this is being done from a microflow this just means they will be subtransactions of your microflow transaction. This might work for your case but it may not be sufficient. You can also end your microflow transaction entirely (see https://forum.mendix.com/questions/2912/Commit-Transaction) and then restart one but it can lead to situations you may not want to deal with.