Multi-instance loop from external worker

@Jonathan_Schmitt, you need to configure “Element Variable” which is an iteration variable for the collection in multi instance activity.

Refer the below example:

@Slf4j
@Component
public class JobProducerDelegate implements JavaDelegate {

  private static final String JOB_LIST = "jobList";

  @Override
  public void execute(DelegateExecution execution) throws Exception {
    String category = (String) execution.getVariable("category");
    log.info("VariableMap:{}", category);
    if ("inventory".equals(category)) {
      execution.setVariable(JOB_LIST, Arrays.asList("2000", "4000"));
    } else if ("order".equals(category)) {
      execution.setVariable(JOB_LIST, Arrays.asList("1000", "3000"));
    } else {
      execution.setVariable(JOB_LIST, Arrays.asList("0000"));
    }
  }

}

@Slf4j
@Component
public class LoggingExecutionListener implements ExecutionListener {

  @Override
  public void notify(DelegateExecution execution) throws Exception {
    log.info("jobType:{}", execution.getVariable("jobType"));
  }

}

BPMN File: JobProducerProcess.bpmn (6.4 KB) DMN File: jobIdentificationRule.dmn (1.9 KB)


Optimize Report:

3 Likes