I think the problem is that the microflow is running in the same context and the same transaction all the time. You could remove the loop and use a recursive microflow call but it would still be the same context and transaction.
I created a module called “Follow Up Microflow” that can execute a microflow when the calling microflow is terminated. It will run in a seperate context and in a seperate transaction. Maybe it helps. Maybe you can just extract some ideas from it and build something on your own. It’s pretty new and is something like a side project. I don’t have a lot of feedback yet but it sounds like it could solve your problem.
Why not use a scheduled event for this? Have it run every 1 minute or so?
It will automatically solve your issue because each invokation will have its own context
This works quite well. In the RunnableImplementation you can configure an infinite loop that executes a Microflow. Before execution you can create a system context. After execution you can destroy the session.
ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
for (int i = 0; i < numberOfThreads; i++) {
Runnable runnable = new RunnableImplementation(logger, microflowToExecute);
executorService.submit(runnable);
}
Hi guys, thanks for your answers! @Andrej, I will not use scheduled events as I want to retrieve as many jobs as possible during peak loads.