cancel
Showing results for 
Search instead for 
Did you mean: 

Repeating Process

ad1
Champ in-the-making
Champ in-the-making
I have a child process that is called  from the main process via call activity. This child activity has a repeat loop. It  keeps sending an email in certain intervals. The Process is terminated eventually my an external java code.

My issues is I tested this in Spring boot and the process could repeat itself and send the email.
When I moved it as a springMVC application deployed on tomcat, the email gets sent only one, and does not repeat.

The parent process is calling the child process "synchronously"
Same is with when the process send the email using the "MailTask".

Any idea why Mail task is not coming back and repeating? As it is SMTP  it should not expect an  acknowledgement, but should continue.


<?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:xsd="http://www.w3.org/2001/XMLSchema" 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="TAEmailProcess" name="TAEmailProcess" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="mailtask1" name="Mail Task" activiti:type="mail">
      <extensionElements>
        <activiti:field name="to">
          <activiti:expression><![CDATA[${taEmailNotification.getAssignees(execution.getId())}]]></activiti:expression>
        </activiti:field>
        <activiti:field name="from">
          <activiti:string><![CDATA[test@theorem.net]]></activiti:string>
        </activiti:field>
        <activiti:field name="subject">
          <activiti:expression><![CDATA[${taEmailNotification.getMailSubject(execution.getId())}]]></activiti:expression>
        </activiti:field>
        <activiti:field name="text">
          <activiti:expression><![CDATA[${taEmailNotification.getMailBody(execution.getId())}]]></activiti:expression>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow10" sourceRef="mailtask1" targetRef="timerintermediatecatchevent2"></sequenceFlow>
    <serviceTask id="Escalate" name="Escalate Task" activiti:expression="${taEmailNotification.escalate(execution.getId())}"></serviceTask>
    <sequenceFlow id="flow15" sourceRef="Escalate" targetRef="exclusivegateway3"></sequenceFlow>
    <sequenceFlow id="flow18" name="No Escalation yet, Just Repeat" sourceRef="exclusivegateway2" targetRef="exclusivegateway3">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${taEmailNotification.repeatNotification(execution.getId())==true}]]></conditionExpression>
    </sequenceFlow>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow22" name="Escalation Required?" sourceRef="exclusivegateway2" targetRef="Escalate">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${taEmailNotification.repeatNotification(execution.getId())==false}]]></conditionExpression>
    </sequenceFlow>
    <intermediateCatchEvent id="timerintermediatecatchevent2" name="TimerCatchEvent">
      <timerEventDefinition>
        <timeDuration>PT3S</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <exclusiveGateway id="exclusivegateway3" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow25" name="Has Filtered Emails?" sourceRef="exclusivegateway3" targetRef="mailtask1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${taEmailNotification.getAssignees(execution.getId())!=null}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow27" sourceRef="startevent1" targetRef="exclusivegateway3"></sequenceFlow>
    <sequenceFlow id="flow28" sourceRef="timerintermediatecatchevent2" targetRef="exclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow29" sourceRef="exclusivegateway3" targetRef="timerintermediatecatchevent2" skipExpression="${taEmailNotification.getAssignees(execution.getId())!=null}"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_TAEmailProcess">
    <bpmndi:BPMNPlane bpmnElement="TAEmailProcess" id="BPMNPlane_TAEmailProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="160.0" y="198.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mailtask1" id="BPMNShape_mailtask1">
        <omgdc:Bounds height="55.0" width="105.0" x="351.0" y="81.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Escalate" id="BPMNShape_Escalate">
        <omgdc:Bounds height="55.0" width="105.0" x="208.0" y="11.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="500.0" y="195.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="timerintermediatecatchevent2" id="BPMNShape_timerintermediatecatchevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="386.0" y="198.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway3" id="BPMNShape_exclusivegateway3">
        <omgdc:Bounds height="40.0" width="40.0" x="240.0" y="195.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="403.0" y="136.0"></omgdi:waypoint>
        <omgdi:waypoint x="403.0" y="198.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="260.0" y="66.0"></omgdi:waypoint>
        <omgdi:waypoint x="260.0" y="195.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
        <omgdi:waypoint x="520.0" y="235.0"></omgdi:waypoint>
        <omgdi:waypoint x="520.0" y="287.0"></omgdi:waypoint>
        <omgdi:waypoint x="260.0" y="290.0"></omgdi:waypoint>
        <omgdi:waypoint x="260.0" y="235.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="39.0" width="100.0" x="340.0" y="289.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow22" id="BPMNEdge_flow22">
        <omgdi:waypoint x="520.0" y="195.0"></omgdi:waypoint>
        <omgdi:waypoint x="520.0" y="38.0"></omgdi:waypoint>
        <omgdi:waypoint x="313.0" y="38.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="39.0" width="100.0" x="530.0" y="82.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow25" id="BPMNEdge_flow25">
        <omgdi:waypoint x="260.0" y="195.0"></omgdi:waypoint>
        <omgdi:waypoint x="403.0" y="136.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="13.0" width="100.0" x="260.0" y="153.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow27" id="BPMNEdge_flow27">
        <omgdi:waypoint x="195.0" y="215.0"></omgdi:waypoint>
        <omgdi:waypoint x="240.0" y="215.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow28" id="BPMNEdge_flow28">
        <omgdi:waypoint x="421.0" y="215.0"></omgdi:waypoint>
        <omgdi:waypoint x="500.0" y="215.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow29" id="BPMNEdge_flow29">
        <omgdi:waypoint x="280.0" y="215.0"></omgdi:waypoint>
        <omgdi:waypoint x="386.0" y="215.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>






4 REPLIES 4

ad1
Champ in-the-making
Champ in-the-making
I saw similar issues reported a year ago (https://forums.activiti.org/content/repeat-timers-issue-activiti-5170). The jobExecutor is true in my case . Here is my  processengine configuration
<code>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="dataSource" ref="dataSource" />
  <!–  <property name="transactionManager" ref="transactionManager" /> –>
  <property name="databaseSchemaUpdate" value="true" />
  <property name="deploymentResources" value="classpath*Smiley Tonguerocesses/*.bpmn" />
  <property name="jobExecutorActivate" value="true" />
  <property name="mailServerPort" value="1025"/>
  <property name="beans">
   <map>
   
   
    <entry key="analytics" value-ref="taNotificationManager" />
    <entry key="analytics1" value="taEmailNotification" />
   </map>



  </property>



</code>

ad1
Champ in-the-making
Champ in-the-making
When I remove the intermediate time the process loops fine, so the issue is with the timer. I did see lot of users complaining about this. For now I went with a very crude way of implementing using   service task and  java sleep timer Smiley Sad

ad1
Champ in-the-making
Champ in-the-making
Resolved it using the following proteries to the engine configuration.
<code>
<property name="jobExecutorActivate" value="true" />
 
  <property name="asyncExecutorActivate" value="true" />
 
      <property name="asyncExecutor" ref="asyncExecutor" />



<bean id="asyncExecutor" class="org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor">
    <property name="defaultAsyncJobAcquireWaitTimeInMillis" value="1000" />
    <property name="defaultTimerJobAcquireWaitTimeInMillis" value="1000" />
  </bean>

      </code>

jbarrez
Star Contributor
Star Contributor
Do keep in mind that this will poll your database every second. That's more load than the default (10 seconds).