cancel
Showing results for 
Search instead for 
Did you mean: 

multiInstanceCharacteristics - Sequential Execution Issue

jagathvijayan
Champ in-the-making
Champ in-the-making
For sequential executions (isSequential="true"), only the first value from the collection gets assigned to all the executions.  For parallel executions (isSequential="false"), it works fine and each execution gets one value from the collection.

Here's the snippet:

    <serviceTask id="servicetask1" name="Serial Multi Task" activiti:class="com.activity.test.SerialMultiDelegate" activiti:assignee="${item}">
       <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${items}" activiti:elementVariable="item" />
    </serviceTask>

public class SerialMultiDelegate implements JavaDelegate {

   @Override
   public void execute(DelegateExecution execution) throws Exception {
      String item = (String) execution.getVariable("item");
      Thread.sleep((System.currentTimeMillis() % 5) * 1000);
      System.out.println("Item: " + item);
   }

}

public class SerialMultiRunner {

   public static void main(String[] args) {
      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
      RepositoryService repositoryService = processEngine
         .getRepositoryService();
      repositoryService.createDeployment().addClasspathResource(
            "diagrams/SerialMulti.bpmn20.xml")
            .deploy();
      RuntimeService runtimeService = processEngine.getRuntimeService();
      Collection<String> items = new ArrayList<String>();
      items.add("East");
      items.add("West");
      items.add("North");
      items.add("South");
      Map<String, Object> processVariables = new HashMap<String, Object>();
      processVariables.put("items", items);
      runtimeService.startProcessInstanceByKey("SerialMulti",
            processVariables);
   }

}

Output (When isSequential="true")

Item: East
Item: East
Item: East
Item: East

Output (When isSequential="false")

Item: East
Item: West
Item: North
Item: South

Has anyone encountered a similar issue? Is this a bug or expected behavior?
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
Is this with 5.5 ?

In 5.4 there was indeed a bug related to javadelegates.

jagathvijayan
Champ in-the-making
Champ in-the-making
Yes, this is with 5.5.

jbarrez
Star Contributor
Star Contributor
Indeed. I checked and it is indeed a bug I overlooked.

Created http://jira.codehaus.org/browse/ACT-806

jbarrez
Star Contributor
Star Contributor
And fixed on trunk!

jagathvijayan
Champ in-the-making
Champ in-the-making
Great, Thanks!! Fix is verified on 5.6-SNAPSHOT build.