cancel
Showing results for 
Search instead for 
Did you mean: 

Async

eugenst
Champ in-the-making
Champ in-the-making
Hi,

for trying out the async feature, I'm trying to deploy a simple process. This process consists of a parallel gateway forking to two script tasks and a second parallel gateway joining them again (see XML below). The two scripting tasks just write out some text to the console. I'm using Activiti version 5.12 with Spring and I'm starting the Activiti process from within a servlet:


  // …
  @RequestMapping(value = "/run", method = RequestMethod.GET)
  public String run(ModelMap model) throws Exception {
    runtimeService.startProcessInstanceByKey("asyncProcess1");
    return "index";
  }
  // …


Now, the problem is that a script task is only executed (i.e., its text is written to the console) if it is set to async='false'. If replacing the script tasks by service tasks that call methods from Spring beans, same problem is observed. What am I doing wrong?

The background is that I would like to have a process that partly executes synchronously and returns some feedback to the user. The other part of the process should fork asynchronously and for instance send some mails (the user interaction is not affected by this).

Here the complete process definition:

<?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="asyncProcess1" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="parallelgateway1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="parallelgateway1" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="parallelgateway1" targetRef="scripttask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow4" sourceRef="scripttask2" targetRef="parallelgateway2"></sequenceFlow>
    <parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow6" sourceRef="parallelgateway2" targetRef="endevent1"></sequenceFlow>
    <scriptTask id="scripttask1" name="Script Task 1" activiti:async="true" scriptFormat="groovy" activiti:autoStoreVariables="true">
      <script>println "Test task 1"</script>
    </scriptTask>
    <sequenceFlow id="flow7" sourceRef="scripttask1" targetRef="parallelgateway2"></sequenceFlow>
    <scriptTask id="scripttask2" name="Script Task 2" activiti:async="true" scriptFormat="groovy" activiti:autoStoreVariables="true">
      <script>println "Test task 2"</script>
    </scriptTask>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_asyncProcess1">
    <bpmndi:BPMNPlane bpmnElement="asyncProcess1" id="BPMNPlane_asyncProcess1">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="110.0" y="273.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="480.0" y="273.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="187.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="421.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55.0" width="105.0" x="260.0" y="212.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask2" id="BPMNShape_scripttask2">
        <omgdc:Bounds height="55.0" width="105.0" x="260.0" y="307.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="145.0" y="290.0"></omgdi:waypoint>
        <omgdi:waypoint x="187.0" y="290.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="227.0" y="290.0"></omgdi:waypoint>
        <omgdi:waypoint x="255.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="260.0" y="239.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="227.0" y="290.0"></omgdi:waypoint>
        <omgdi:waypoint x="312.0" y="307.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="365.0" y="334.0"></omgdi:waypoint>
        <omgdi:waypoint x="441.0" y="310.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="461.0" y="290.0"></omgdi:waypoint>
        <omgdi:waypoint x="480.0" y="290.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="365.0" y="239.0"></omgdi:waypoint>
        <omgdi:waypoint x="441.0" y="270.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


Thanks a lot for your comments.

Eugen
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Do you have the job executor enabled?
This should just work fine with async=true

Best regards,

eugenst
Champ in-the-making
Champ in-the-making
You're right, my configuration was wrong.

Thanks a lot!