cancel
Showing results for 
Search instead for 
Did you mean: 

Does Job Executor launch Service Tasks more than once?

ct1
Champ in-the-making
Champ in-the-making
I made process for a user to launch in Explorer that polls for a file until it finds it or exceeds a set timelimit.  I initially used an IntermediateTimerEvent, but I kept getting exceptions that the time was simultaneously updated by another transaction.  So, I wrote a Java class to run in a loop looking for the file, sleeping one minute, and looking for the file again.  The problem I encounter is that about five minutes after the service task is started, it gets started again (presumably by the JobExecutor), and abouit five minutes later it gets started a third time.  All I really need is for the Service Task to be launched one time and for the engine to wait at the Exclusive Gateway that follows the Service Task.

Does the JobExcutor, or the mechanism that launches the Java classes that implement Service Tasks, have retry logic built into it?  If so, how can I control it?  Is that what the documentation below indicates, or is there so other explanation?  Please see the Annotated Log file below.

Here is the BPMN20 file:


<?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="CheckForAFile" name="CheckForAFile">
    <documentation>Place documentation for the 'CheckForAFile' process here.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="checkFileExists"></sequenceFlow>
    <serviceTask id="checkFileExists" name="Check File Exists" activiti:async="true" activiti:class="opt.argo.com.CheckForFile"></serviceTask>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow2" name="" sourceRef="checkFileExists" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="doesExist" name="Yes" sourceRef="exclusivegateway1" targetRef="logThatFileExists">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${fileExists == true}]]></conditionExpression>
    </sequenceFlow>
    <scriptTask id="logThatFileExists" name="Log That File Exists" scriptFormat="groovy">
      <script><![CDATA[print "File does exist. \n"]]></script>
    </scriptTask>
    <sequenceFlow id="fileNotExist" name="File Does Not Exist" sourceRef="exclusivegateway1" targetRef="logThatFileNotExist">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${fileExists != true}]]></conditionExpression>
    </sequenceFlow>
    <scriptTask id="logThatFileNotExist" name="Log That File Does Not Exist" scriptFormat="groovy">
      <script><![CDATA[print "File does NOT exist. \n"]]></script>
    </scriptTask>
    <endEvent id="fileExistEnd" name="File Exits End"></endEvent>
    <sequenceFlow id="flow5" name="" sourceRef="logThatFileExists" targetRef="fileExistEnd"></sequenceFlow>
    <endEvent id="fileNotExistEnd" name="File Not Exist"></endEvent>
    <sequenceFlow id="flow6" name="" sourceRef="logThatFileNotExist" targetRef="fileNotExistEnd"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_CheckForAFile">
    <bpmndi:BPMNPlane bpmnElement="CheckForAFile" id="BPMNPlane_CheckForAFile">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="150" y="220"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="checkFileExists" id="BPMNShape_checkFileExists">
        <omgdc:Bounds height="55" width="105" x="230" y="210"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40" width="40" x="430" y="217"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="logThatFileExists" id="BPMNShape_logThatFileExists">
        <omgdc:Bounds height="55" width="105" x="520" y="120"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="logThatFileNotExist" id="BPMNShape_logThatFileNotExist">
        <omgdc:Bounds height="55" width="105" x="520" y="300"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="fileExistEnd" id="BPMNShape_fileExistEnd">
        <omgdc:Bounds height="35" width="35" x="680" y="130"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="fileNotExistEnd" id="BPMNShape_fileNotExistEnd">
        <omgdc:Bounds height="35" width="35" x="740" y="310"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="185" y="237"></omgdi:waypoint>
        <omgdi:waypoint x="230" y="237"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="335" y="237"></omgdi:waypoint>
        <omgdi:waypoint x="430" y="237"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="doesExist" id="BPMNEdge_doesExist">
        <omgdi:waypoint x="450" y="217"></omgdi:waypoint>
        <omgdi:waypoint x="450" y="147"></omgdi:waypoint>
        <omgdi:waypoint x="520" y="147"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="fileNotExist" id="BPMNEdge_fileNotExist">
        <omgdi:waypoint x="450" y="257"></omgdi:waypoint>
        <omgdi:waypoint x="450" y="327"></omgdi:waypoint>
        <omgdi:waypoint x="520" y="327"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="625" y="147"></omgdi:waypoint>
        <omgdi:waypoint x="680" y="147"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="625" y="327"></omgdi:waypoint>
        <omgdi:waypoint x="740" y="327"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Here is my Java class:


package opt.argo.com;

import java.io.File;

public class CheckForFile implements JavaDelegate
{   
   @Override   
   public void execute(DelegateExecution execution) throws Exception
   {
      Calendar now = Calendar.getInstance();
      
      System.out.println("CheckForFile.execute() was called at "
                  + now.getTime());
      
      System.out.println("Current thread is "
                  + Thread.currentThread().getName());
      
      long startTime = System.currentTimeMillis();
      
      long maxRunTimeInSeconds = 900L;  // 15 minutes
      long maxRunTimeInMilis = maxRunTimeInSeconds * 1000;
      
      // May want to use the DelegateExecution object to provide the
      // file and path names.  For now, just put in values to test with.
      
      String fileAndPathName = constructFileAndPathName();
      
      boolean fileExists = false;
      
      int counter = 0;
      
      // Will try at one-minute intervals for a maximum of 10 minutes or until
      // the file is found.
      // while(counter < 10)
      
      // Will try at one-minute intervals endlessly
      //while(true)
      
      // Will try until time allowed runs out.
      while(System.currentTimeMillis() < (startTime + maxRunTimeInMilis))
      {
         counter++;
         
         fileExists = lookForFile(fileAndPathName);
         
         System.out.println("In CheckForFile.execute() set fileExists = "
                     + fileExists + " when counter was "
                     + counter + ".  Current thread is "
                     + Thread.currentThread().getName());         
         
         if(fileExists == true)
         {
            break;
         }
         else
         {
            try
            {
               // One minute
               Thread.sleep(60000L);
            }
            catch(Exception e1)
            {
               System.out.println("CheckForFile.execute() caught "
                           + "exception that interrupted the sleep.");
               e1.printStackTrace();
               
               throw new Exception("CheckForFile sleep was interrupted.");
            }
         }
      }
      
      execution.setVariable("fileExists", fileExists);      
      
   }
   
   private boolean lookForFile(String fileAndPathName)
   {
      System.out.println("CheckForFile.lookForFile() was called with "
                  + "fileAndPathName = \"" + fileAndPathName + "\".");
      
      boolean fileFound = false;
      
      if(fileAndPathName != null && fileAndPathName.length() > 0)
      {
         File aFile = new File(fileAndPathName);
         
         if(aFile.exists())
         {
            fileFound = true;
         }
         else
         {
            fileFound = false;
         }
         
      }
            
      System.out.println("In CheckForFile.lookForFile() set fileFound = "
                     + fileFound);
      
      return fileFound;
   }
   
   private String constructFileAndPathName()
   {
      String separator = new String();
      separator = System.getProperty("file.separator");
      
      String theFilePath = new String("C:" + separator + "Users" + separator
               + "thomacha"
               + separator + "DataFiles" + separator + "ForTest"
               + separator);
      
      String theFileName = new String("theFileToLookFor.txt");
      
      String fileAndPathName = new String(theFilePath + theFileName);
      
      return fileAndPathName;
   }
}


Here is an annotated log file and History table entries:



[color=#BF0000]—PROCESS START WITH THREAD 2[/color]
CheckForFile.execute() was called at Tue Dec 06 08:48:40 CST 2011
Current thread is pool-1-thread-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 1.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 2.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 3.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 4.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 5.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 6.  Current thread is pool-1-threa
d-2

[color=#BF0000]— FIVE MINUTES LATER PROCESS WAS STARTED IN THREAD 3 (THREAD 2 CONTINUES ITS WORK TOO.)[/color]
CheckForFile.execute() was called at Tue Dec 06 08:53:41 CST 2011
Current thread is pool-1-thread-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 1.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 7.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 2.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 8.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 3.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 9.  Current thread is pool-1-threa
d-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 4.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 10.  Current thread is pool-1-thre
ad-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 5.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 11.  Current thread is pool-1-thre
ad-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 6.  Current thread is pool-1-threa
d-3

[color=#BF0000]— FIVE MINUTES LATER PROCESS WAS STARTED THE THIRD TIME, NOW IN THREAD 1 (THREADS 2 AND 3 CONTINUE WORKING TOO.)[/color]
CheckForFile.execute() was called at Tue Dec 06 08:58:41 CST 2011
Current thread is pool-1-thread-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 1.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 12.  Current thread is pool-1-thre
ad-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 7.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 2.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 13.  Current thread is pool-1-thre
ad-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 8.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 3.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 14.  Current thread is pool-1-thre
ad-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 9.  Current thread is pool-1-threa
d-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 4.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 15.  Current thread is pool-1-thre
ad-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 10.  Current thread is pool-1-thre
ad-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 5.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 16.  Current thread is pool-1-thre
ad-2
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 11.  Current thread is pool-1-thre
ad-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 6.  Current thread is pool-1-threa
d-1

[color=#BF0000]— THREAD 2 (the first thread launched) ENDS (without finding file, this was expected)[/color]
File does NOT exist.
[color=#0000FF]— NOW,WHY IS IT LOOKING FOR JOB 9420?  JOB 9419 RAN THE THE SERVICE TASK (See History Below)[/color]
Dec 6, 2011 9:04:40 AM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: No job found with id '9420'
        at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:57)
        at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java
:24)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInte
rceptor.java:42)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInter
ceptor.java:42)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.j
ava:130)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.jav
a:40)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
        at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:36)

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
[color=#0000FF]Exception in thread "pool-1-thread-2" org.activiti.engine.ActivitiException: No job found with id '9
420'[/color]        at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:57)
        at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java
:24)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInte
rceptor.java:42)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInter
ceptor.java:42)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.j
ava:130)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.jav
a:40)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
        at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:36)

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
      
[color=#BF0000]— THREAD 3 AND THREAD 1 CONTINUE[/color]
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 12.  Current thread is pool-1-thre
ad-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 7.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 13.  Current thread is pool-1-thre
ad-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 8.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 14.  Current thread is pool-1-thre
ad-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 9.  Current thread is pool-1-threa
d-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 15.  Current thread is pool-1-thre
ad-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 10.  Current thread is pool-1-thre
ad-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 16.  Current thread is pool-1-thre
ad-3
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 11.  Current thread is pool-1-thre
ad-1

[color=#BF0000]— THREAD 3 ENDS[/color]

File does NOT exist.
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 12.  Current thread is pool-1-thre
ad-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 13.  Current thread is pool-1-thre
ad-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 14.  Current thread is pool-1-thre
ad-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 15.  Current thread is pool-1-thre
ad-1
CheckForFile.lookForFile() was called with fileAndPathName = "C:\Users\thomacha\DataFiles\ForTest\th
eFileToLookFor.txt".
In CheckForFile.lookForFile() set fileFound = false
In CheckForFile.execute() set fileExists = false when counter was 16.  Current thread is pool-1-thre
ad-1

[color=#BF0000]— THREAD 1 ENDS[/color]
File does NOT exist.


—- History

—- ACT_HI_PROCINST
[size=50]

9419   9419   CheckForAFile:1:8525   2011-12-06 08:48:40.61   2011-12-06 09:14:41.437   1560827   kermit   startevent1   fileNotExistEnd
[/size]   
[color=#BF0000]—- ACT_HI_ACTINST - Shows three executions of the Service Task, when the BPMN20 file just asked for one.[/color]
[size=50]
9421   CheckForAFile:1:8525   9419   9419   checkFileExists      Check File Exists          serviceTask      2011-12-06 08:48:40.626   2011-12-06 09:04:40.62   959994
9425   CheckForAFile:1:8525   9419   9419   exclusivegateway1   Exclusive Gateway          exclusiveGateway   2011-12-06 09:04:40.62   2011-12-06 09:04:40.621   1
9426   CheckForAFile:1:8525   9419   9419   logThatFileNotExist   Log That File Does Not Exist scriptTask         2011-12-06 09:04:40.621   2011-12-06 09:04:40.67   49

9422   CheckForAFile:1:8525   9419   9419   checkFileExists      Check File Exist          serviceTask      2011-12-06 08:53:41.035   2011-12-06 09:09:41.026   959991
9428   CheckForAFile:1:8525   9419   9419   exclusivegateway1   Exclusive Gateway          exclusiveGateway   2011-12-06 09:09:41.026   2011-12-06 09:09:41.026   0
9429   CheckForAFile:1:8525   9419   9419   logThatFileNotExist   Log That File Does Not Exist scriptTask         2011-12-06 09:09:41.026   2011-12-06 09:09:41.074   48

9423   CheckForAFile:1:8525   9419   9419   checkFileExists      Check File Exists          serviceTask      2011-12-06 08:58:41.419   2011-12-06 09:14:41.407   959988
9431   CheckForAFile:1:8525   9419   9419   exclusivegateway1   Exclusive Gatewa          exclusiveGateway   2011-12-06 09:14:41.407   2011-12-06 09:14:41.407   0
9432   CheckForAFile:1:8525   9419   9419   logThatFileNotExist   Log That File Does Not Exist scriptTask         2011-12-06 09:14:41.407   2011-12-06 09:14:41.436   29[/size]

8 REPLIES 8

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
This is normal behaviour. The jobexecutor assumes that tasks it needs to run take less time than 5 minutes. If they take longer, it assumes the job is stuck and it re-executes it. Solving the problem the way you do in the java class is kind of wrong… For long running external jobs use the send/receive mechanism.

Ronald

What is the 'send/receive' mechanism? (I'm running into a problem similar to the one described in this thread – on activiti 5.15.1)

keymaster
Champ in-the-making
Champ in-the-making
Hello

and how is the reexecution trigger? It it done by setting then JOB.LOCK_EXP_TIME_ to "now + 5 Min"?

Regards, Wolf

frederikherema1
Star Contributor
Star Contributor
Yes, it is. The expiration-time can be altered by overriding the Job-executor. Keep in mind, though, that certain databases have a transaction-timeout that may occur when, when transaction is kept open too long when executing the long-running job.

keymaster
Champ in-the-making
Champ in-the-making
Hello Frederik,
can you tell me where the DB transaction timeout is configured and how it is set by default for ORACLE.
Regards, Wolf

frederikherema1
Star Contributor
Star Contributor
keymaster, please google for these settings for oracle, presume it's a property in the datasource configuration/jdbc-url…

rajkumarchari82
Champ in-the-making
Champ in-the-making
Hi Fred,

This might a simple question, please do confirm the below.
I hope the above is the case only with the RUN execution task and not for a wait task(Wait Timer Event definition ) as the sole purpose of to to wait for longer durations than 5mins.

jbarrez
Star Contributor
Star Contributor
wait states (eg receive task) do not keep any transaction open.