cancel
Showing results for 
Search instead for 
Did you mean: 

Async continuations: 2 simple script tasks

nickerox
Champ in-the-making
Champ in-the-making
Hi everybody,

Can anyone help me to understand what it is wrong in this code? Two simple script tasks (one of them "async=true") still works in sequential mode. The Activiti version is 5.14.  Many thx in advance


<?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="myProcess" name="My process" isExecutable="true">
    <endEvent id="endevent1" name="End"></endEvent>
    <scriptTask id="scripttask1" name="&gt; 5" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>int i = 5;
while(i &lt; 10) {
   Thread.sleep(1000);
   println(i);
   i++;
}
   </script>
    </scriptTask>
    <startEvent id="startevent1" name="Start"></startEvent>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow6" sourceRef="startevent1" targetRef="parallelgateway1"></sequenceFlow>
    <sequenceFlow id="flow7" sourceRef="parallelgateway1" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="parallelgateway1" targetRef="scripttask2"></sequenceFlow>
    <scriptTask id="scripttask2" name="&lt; 5" activiti:async="true" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>int i = 0;
while(i &lt;5) {
Thread.sleep(1000);
println(i);
i++;
}</script>
    </scriptTask>
    <parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow9" sourceRef="scripttask2" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow10" sourceRef="scripttask1" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow11" sourceRef="parallelgateway2" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="580.0" y="230.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55.0" width="105.0" x="291.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="50.0" y="230.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="180.0" y="227.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask2" id="BPMNShape_scripttask2">
        <omgdc:Bounds height="55.0" width="105.0" x="291.0" y="300.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="470.0" y="227.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="85.0" y="247.0"></omgdi:waypoint>
        <omgdi:waypoint x="180.0" y="247.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="200.0" y="227.0"></omgdi:waypoint>
        <omgdi:waypoint x="200.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="291.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="200.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="200.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="291.0" y="327.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="396.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="489.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="490.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="396.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="490.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="490.0" y="227.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="510.0" y="247.0"></omgdi:waypoint>
        <omgdi:waypoint x="570.0" y="247.0"></omgdi:waypoint>
        <omgdi:waypoint x="580.0" y="247.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

2 REPLIES 2

nickerox
Champ in-the-making
Champ in-the-making
Sorry, I`ve not considered  scriptTask attribute <b>activiti:exclusive="false"</b>. It works.

jbarrez
Star Contributor
Star Contributor
Yes, the default is 'true', since for 'normal' users this makes most sense (chance for optimistic locking exception is high in case of jobs for the same process).