AnsweredAssumed Answered

job executor failed to process all jobs

Question asked by tonyado on Aug 29, 2016
Latest reply on Aug 30, 2016 by tonyado
FYI. I am running async service task test, and my unit test code is:
<blockcode>
public void testParallel() throws Exception {
        final String deploymentId = repositoryService.createDeployment().addClasspathResource("ParallelServiceTask.bpmn20.xml")
                .deploy().getId();
        System.out.println("deployment id: " + deploymentId);
        // start process
        runtimeService.startProcessInstanceByKey("test_Parallel");
        assertEquals(2, managementService.createJobQuery().count());

        waitForJobExecutorToProcessAllJobs(100 * 1000L, 250L);

        // the job is done
        assertEquals(0, managementService.createJobQuery().count());

        ProcessInstance pi = runtimeService.createProcessInstanceQuery().processDefinitionId("test_Parallel").singleResult();
        System.out.println("end: " + pi.isEnded());
    }
</blockcode>

the process definition xml is quite simple:
<blockcode>
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:activiti="http://activiti.org/bpmn"
             targetNamespace="ActivitiDemo">

    <process id="test_Parallel" name="The simple group deploy process">

        <startEvent id="test_Parallel_start"/>

        <sequenceFlow sourceRef='test_Parallel_start'
                      targetRef='fork_gateway'/>

        <parallelGateway id="fork_gateway" name="Fork"/>

        <serviceTask id="parallel_task1" name="Task1" activiti:class="com.westudio.activiti.OffTrafficService"
                     activiti:async="true" activiti:exclusive="false"/>
        <sequenceFlow sourceRef="fork_gateway" targetRef="parallel_task1"/>

        <serviceTask id="parallel_task2" name="Task2"
                     activiti:class="com.westudio.activiti.DownloadBundleService" activiti:async="true"
                     activiti:exclusive="false"/>
        <sequenceFlow sourceRef="fork_gateway" targetRef="parallel_task2"/>

        <parallelGateway id="join_gateway" name="Join"/>
        <sequenceFlow sourceRef="parallel_task1" targetRef="join_gateway"/>
        <sequenceFlow sourceRef="parallel_task2" targetRef="join_gateway"/>

        <endEvent id="test_Parallel_end"/>
        <sequenceFlow sourceRef="join_gateway" targetRef="test_Parallel_end"/>

    </process>

</definitions>
</blockcode>

and the
activiti.cfg.xml
is:
<blockcode>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="processEngineConfiguration"
          class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">

        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true"/>
        <property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
        <property name="jdbcUsername" value="root"/>
        <property name="jdbcPassword" value="root"/>

        <!– Database configurations –>
        <property name="databaseSchemaUpdate" value="true"/>

        <!– job executor configurations –>
        <property name="jobExecutorActivate" value="false"/>

    </bean>

</beans>
</blockcode>

all the java delegate classes implement
JavaDelegate
, just like below:
<blockcode>
public class OffTrafficService implements JavaDelegate {
    public void execute(DelegateExecution execution) throws Exception {
        System.out.println("start off traffic service task: " + Calendar.getInstance().get(Calendar.SECOND));
        Thread.sleep(10 * 1000);
        System.out.println("off traffic get executed");
    }
}
</blockcode>

From the test log, I can see both service tasks get executed, but the job executor will not exit even I set a quite long wait time. The service tasks are definitely finished in this wait time. I don't know what is wrong, hope someone can help me, thanks a lot.

Outcomes