List<String> processIds = Lists.newArrayList();
for (Machine machine : machines) {
final String perMachineProcessBusinessKey = String.format("%s-%s-%s",
execution.getProcessBusinessKey(), type, machine.getExternalId());
ProcessInstance perMachineProcess = processEngine.getRuntimeService().startProcessInstanceByKey(
processKey, perMachineProcessBusinessKey,
ImmutableMap.<String, Object>of(CoreProcessVariables.POOL, pool,
CoreProcessVariables.POOL_BUSINESS_KEY, poolBusinessKey,
CoreProcessVariables.IS_CACHED_IMAGE, pool.getSoftware().isCachedImage(),
MACHINE, machine));
LOG.info("Started background '" + type + "' process {} ({}) for machine {}",
new Object[]{perMachineProcessBusinessKey, perMachineProcess.getId(), machine.getExternalId()});
processIds.add(perMachineProcess.getId());
}
LOG.info("Saving process IDs {} as {}", processIds, resultVariable);
execution.setVariable(resultVariable, processIds);
}