Looking at the community commons in my project, I can't find the specified method. The Java action in my Community Commons is called executeMicroflowInBackground. This Java action does more than simply run a microflow asynchronously: e.g. it also ensures they are placed in a queue if there is more than one. The documentation also specifically states this limitation (that the currentUser is unavailable). However, creating your own Java action using Core.executeAsync should be possible, there is nothing to indicate that this will fail.
To extend the current code, you could go two ways:
The solution in Misc.java is:
public static Boolean runMicroflowInBackground(final IContext context, final String microflowName,
final IMendixObject paramObject)
{
final ISession session = context.getSession();
if (paramObject != null)
session.retain(paramObject);
MFSerialExecutor.instance().execute(new Runnable() {
@Override
public void run()
{
try
{
// Disabled (Axel Brink 16-10-2014)
/* IContext c = Core.createSystemContext();
if (paramObject != null) {
Core.executeAsync(c, microflowName, true, paramObject).get(); //MWE: somehow, it only works with system context... well thats OK for now.
}
else
Core.executeAsync(c, microflowName, true, new HashMap<String,Object>()).get(); //MWE: somehow, it only works with system context... well thats OK for now.
*/
// Modified version below (Axel Brink 16-10-2014)
if (paramObject != null) {
Core.executeAsync(context, microflowName, true, paramObject).get();
}
else {
Core.executeAsync(context, microflowName, true, new HashMap<String,Object>()).get();
}
}
catch (Exception e)
{
throw new RuntimeException("Failed to run Async: "+ microflowName + ": " + e.getMessage(), e);
}
finally {
if (paramObject != null)
session.release(paramObject.getId());
}
}
});
return true;
}