Not sure what you are looking for exactly but I build something like that for a project I worked on a while back (microflow has 1 inputparameter of type "object") to run 3 data intensive flows in parallel (with the aim of dividing the load over multiple cpu's) maybe it is of help to you. A simplified version would be:
List<Future<Object>> futures = new ArrayList<Future<Object>>();
for (int i = 0; i < objectList.size(); i++) {
Future<Object> f = Core.executeAsync(context, microflowName, objectList.get(i).getMendixObject());
futures.add(f);
}
//wait for all async actions to finish
//get will also throw an exception if an exception was thrown during the execution of an async action
for (Future<Object> f: futures)
f.get();
//all async actions are finished
Events on the domain model run in parallel
To successfully execute a truly concurrent microflow you need to build a java class as follows:
package your.tools;
import java.util.Map; import com.mendix.systemwideinterfaces.core.IContext;
public class StartMicroflow implements Runnable{ private IContext context; private Map<string,object> paramaters; private String microflowName;
public StartMicroflow(IContext context, String microflowName, Map<String, Object> parameters){
this.context = context.getSession().createContext();
this.microflowName = microflowName;
this.paramaters = parameters;
}
@Override
public void run() {
try{
com.mendix.core.Core.execute(this.context, this.microflowName,this.paramaters);
}
catch(com.mendix.core.CoreException ex){
}
}
}
To call this class all you need are the current context, the microflows name and the microflows parameters to be called from a Java Action. The example does not have parameters but these can be added easily;
public Boolean executeAction() throws Exception
{
// BEGIN USER CODE
ExecutorService exec = Executors.newCachedThreadPool();
exec.execute(new StartMicroflow (getContext(),this.microflowName, null));
return true;
// END USER CODE
}