cancel
Showing results for 
Search instead for 
Did you mean: 

job executor failed to process all jobs

tonyado
Champ in-the-making
Champ in-the-making
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.
6 REPLIES 6

warper
Star Contributor
Star Contributor
Hi!
It seems you did not enable job executor: jobExecutorActivate=false in your settings.

tonyado
Champ in-the-making
Champ in-the-making
hi Wraper, I just tried to set <code>jobExecutorActivate=true</code>, it has no help with this. Still the same problem. And according to the user guide, this value should be false imo.

warper
Star Contributor
Star Contributor
Hi TonyAdo,
Currently you might experience issues with parallel gateway due to "exclusive=false" in your tasks definitions.
Please take a look at activiti user guide, section 8.7.3. Exclusive Jobs. In particular, it mentions your scenario:
Why is this a problem? Since the service tasks are configured using an asynchronous continuation, it is possible that the corresponding jobs are all acquired at the same time and delegated to different worker threads by the JobExecutor. The consequence is that the transactions in which the services are executed and in which the 3 individual executions arrive at the parallel join can overlap. And if they do so, each individual transaction will not "see", that another transaction is arriving at the same parallel join concurrently and thus assume that it has to wait for the others. However, if each transaction assumes that it has to wait for the other ones, none will continue the process after the parallel join and the process instance will remain in that state forever.

Also, please make sure jobExecutor actually runs and executes jobs. Even if process stalls at parallelgateway you should see two executions at about this stage of process.

tonyado
Champ in-the-making
Champ in-the-making
Hi, Wraper

Thanks for your detailed reply. But if I remove <code>exclusive=false</code>, the service tasks are executed in sequence not in real parallel. From the test output:
<blockcode>
Mon Aug 29 21:21:24 CST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
deployment id: 1
Mon Aug 29 21:21:26 CST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Mon Aug 29 21:21:26 CST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
start download bundle service task: 26
start off traffic service task: 26
download bundle get executed
off traffic get executed

org.activiti.engine.ActivitiException: time limit of 30000 was exceeded

at org.activiti.engine.impl.test.AbstractActivitiTestCase.waitForJobExecutorToProcessAllJobs(AbstractActivitiTestCase.java:213)
at com.westudio.activiti.ParallelServiceTaskTest.testParallel(ParallelServiceTaskTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at junit.framework.TestCase.runTest(TestCase.java:176)
at org.activiti.engine.impl.test.PvmTestCase.runTest(PvmTestCase.java:65)
at junit.framework.TestCase.runBare(TestCase.java:141)
at org.activiti.engine.impl.test.AbstractActivitiTestCase.runBare(AbstractActivitiTestCase.java:86)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:253)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)


Process finished with exit code 255
</blockcode>
we can see service tasks really get executed, the problem is job executor will exceeded the time limit, and the process will never reach to the end state.

warper
Star Contributor
Star Contributor
Hi TonyAdo!
Well, it's expected to be so. Each execution updated its own transaction and doesn't see data from another transaction. To see it they need to be run in one transaction context and it happens only if they already run in exclusive mode.
To be honest, I've never joined non-exclusive executions.
I think you can add dummy script tasks with asynch=true and exclusive=true flags after your service tasks and they will go to parallel gateway and join properly. It will take a couple more async jobs, but theorethcally it should fix the issue.

tonyado
Champ in-the-making
Champ in-the-making
Thanks Wraper, I will give a try to see whether it works.