AnsweredAssumed Answered

asyncJobLockTimeInMillis not work in DefaultAsyncJobExecutor

Question asked by chenyh on May 11, 2016
Latest reply on May 19, 2016 by chenyh
Hello, I recently integrated the latest Activiti 5.20.0 with my Web App using spring. part of my config file is just as follow:

        <bean id="asyncExecutor" class="org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor">
      <property name="corePoolSize" value="10" />
      <property name="maxPoolSize" value="100" />
      <property name="keepAliveTime" value="5000" />
      <property name="queueSize" value="100" />
      <property name="maxTimerJobsPerAcquisition" value="30" />
      <property name="maxAsyncJobsDuePerAcquisition" value="30" />
      <property name="defaultAsyncJobAcquireWaitTimeInMillis" value="1000" />
      <property name="defaultTimerJobAcquireWaitTimeInMillis" value="1000" />
      <property name="timerLockTimeInMillis" value="300000" />
      <property name="asyncJobLockTimeInMillis" value="300000" />
   </bean>

    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
        <property name="dataSource" ref="actDataSource" />
        <property name="transactionManager" ref="actTxManager" />
        <property name="jobExecutorActivate" value="false" />
        <property name="asyncExecutorEnabled" value="true" />
        <property name="asyncExecutorActivate" value="true" />
        <property name="dbHistoryUsed" value="false" />
        <property name="dbIdentityUsed" value="false" />
        <property name="history" value="activity" />
        <property name="databaseType" value="mssql" />
        <property name="bulkInsertEnabled" value="false" />
        <property name="deploymentResources" value="classpath*:/diagrams/autodeploy/*.bpmn" />
        <property name="deploymentMode" value="single-resource" />
        <property name="asyncExecutor" ref="asyncExecutor" />
   </bean>

All runs well, but when I try to shut down the activiti engine when it runs a async job in java service task:
<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="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:expression="#{singlePayOrderService.virtualAcctTransD2Settle(singlePayOrderId)}"></serviceTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
  </process>
</definitions>

the service task's logic can be ignored, because I just debug the app, and shut down the engine when it run into the java code. After the lock time expired, I restart my activie engine, but no retry will executed!
So I checked the code, the async job executor use "AcquireTimerJobsRunnable" and "AcquireAsyncJobsDueRunnable" to fetch the "to be executed jobs", and use "AcquireTimerJobsCmd" and "AcquireAsyncJobsDueCmd" to execute the search query.
however, when I deep it to the sql file in "job.xml", it shows the sql id is "selectNextTimerJobsToExecute","selectAsyncJobsDueToExecute". Neither of the 2 sql can select the LOCK_EXP_TIME_ with the TYPE_="message".
Moreover, I try to switch the async executor to the legacy jobExecutor, it works fine. I mean when I restart the activiti engine, it will retry the job when lock time expired. I still check the code, which use the "selectNextJobsToExecute" sql, and works file.
Please kindly advise whether I should do it my self or there should be some reason to disable the auto retry mechanism.
Thanks in advance.

Outcomes