AnsweredAssumed Answered

How to multi instance on sub process

Question asked by nbuso on Oct 31, 2012
Latest reply on Nov 5, 2012 by jbarrez
Hi,

I'm trying to obtain concurrent execution of a subprocess, but the behaviour is not what expected; this is how the subprocess is defined:

    <subProcess id="PerDomainSubProcess" name="PerDomainSubProcess" activiti:async="true">
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="domainIds.list" activiti:elementVariable="domainId"></multiInstanceLoopCharacteristics>
      <startEvent …..

I was thinking the subprocesses would be started for any element of the collection in parallel (concurrently), but it's not happening, the subprocesses created are executed sequentially.

Am I missing something? Can somebody point me on how to achieve this behaviour?

n.

P.S.: I was trying to follow the suggestions I found in this post http://forums.activiti.org/en/viewtopic.php?f=8&t=4746&p=18607&hilit=concurrent+subprocess#p18607

——————

I created a simple process: it accept in input a list of values separated by comma (a,b,c,d) and in a subprocess it print 100000 line per element of the list. The print is done by a groovy script.

If I execute the process I can notice in the log that the rows are all printed in sequence. The subprocess is async and multi instance on the list of inputs.
I did something wrong? isn't possible to obtain concurrency?
Do I need to raise a JIRA ticket?

Somebody can give me some hints on this?


I paste here the process, because the forum upload seam not to work.


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="process1" name="process1">
    <startEvent id="startevent1" name="Start" activiti:initiator="initiator"></startEvent>
    <userTask id="usertask1" name="Data Inputs" activiti:assignee="${initiator}">
      <extensionElements>
        <activiti:formProperty id="ids"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <scriptTask id="scripttask1" name="variableList" scriptFormat="groovy">
      <script><![CDATA[def ids = execution.getVariable("ids");
def idsList = ids.tokenize(",");
execution.setVariable("ids.list", idsList);]]></script>
    </scriptTask>
    <subProcess id="subprocess1" name="Sub Process" activiti:async="true">
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="ids.list" activiti:elementVariable="identifier"></multiInstanceLoopCharacteristics>
      <startEvent id="startevent2" name="Start"></startEvent>
      <scriptTask id="scripttask2" name="simple printout" scriptFormat="groovy">
        <script><![CDATA[for (idxVar in 0..100000) {
println(execution.getVariable("identifier")+"_"+idxVar);
}]]></script>
      </scriptTask>
      <endEvent id="endevent1" name="End"></endEvent>
      <sequenceFlow id="flow4" name="" sourceRef="startevent2" targetRef="scripttask2"></sequenceFlow>
      <sequenceFlow id="flow5" name="" sourceRef="scripttask2" targetRef="endevent1"></sequenceFlow>
    </subProcess>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="scripttask1" targetRef="subprocess1"></sequenceFlow>
    <sequenceFlow id="flow6" name="" sourceRef="subprocess1" targetRef="endevent2"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_process1">
    <bpmndi:BPMNPlane bpmnElement="process1" id="BPMNPlane_process1">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="90" y="150"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55" width="105" x="170" y="140"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55" width="105" x="330" y="140"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess1" id="BPMNShape_subprocess1" isExpanded="true">
        <omgdc:Bounds height="205" width="381" x="510" y="65"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent2" id="BPMNShape_startevent2">
        <omgdc:Bounds height="35" width="35" x="550" y="152"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask2" id="BPMNShape_scripttask2">
        <omgdc:Bounds height="55" width="105" x="630" y="142"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="790" y="152"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="585" y="169"></omgdi:waypoint>
        <omgdi:waypoint x="630" y="169"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="735" y="169"></omgdi:waypoint>
        <omgdi:waypoint x="790" y="169"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35" width="35" x="940" y="150"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="125" y="167"></omgdi:waypoint>
        <omgdi:waypoint x="170" y="167"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="275" y="167"></omgdi:waypoint>
        <omgdi:waypoint x="330" y="167"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="435" y="167"></omgdi:waypoint>
        <omgdi:waypoint x="510" y="167"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="891" y="167"></omgdi:waypoint>
        <omgdi:waypoint x="940" y="167"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Outcomes