AnsweredAssumed Answered

[Activiti 5.10] JobExecutor executes already acquired and running job again

Question asked by jmonte83 on Aug 8, 2013
Latest reply on Aug 9, 2013 by trademak
Hi everyone,

Let me first clarify our Activiti environment setup:

We are currently using version 5.10 of Activiti.

We have the Activiti engine integrated in our artifact which also includes processes and corresponding Java classes. The JobExecutor uses the implementation org.activiti.engine.impl.jobexecutor.DefaultJobExecutor which is configured with settings:

jobExecutor.setCorePoolSize(1);
jobExecutor.setMaxPoolSize(1);

The JobExecutor is manually started after the Spring Context has been successfully initialized.

This artifact is deployed on two servers. Both Activiti engines work on the same database.

For analysis purposes, I have set up a separate activiti_engine.log file where log messages from package org.activiti.engine are written to.

We have the following scenario:

A job for a process instance/ execution is acquired by the JobExecutor and is then executed. The execution starts at an async service task, traverses two exclusive gateways, then executes a sync service task and finally ends up in an end node. For some unknown reason, the execution of the sync service task lasts 17 seconds. Normally, the execution of the mentioned sync service task lasts around 3 seconds.

5 seconds after the first acquisition of the job mentioned above, the same job is again acquired by the JobExecutor and then executed. All process elements mentioned above are again traversed.

The same job is therefore executed twice by the same Job Executor.

As far as I understand, a job is (by default) locked by the JobExecutor for 5 minutes. Also the unique id of the JobExecutor is set for a job when it is aquired. Does this locking only prevent that another JobExecutor can acquire this job concurrently or should it also prevent that the same JobExecutor acquires/ executes a job twice during this 5 minutes?

Is the described behavior the expected/ normal way Activiti works? I would expect that Activiti ensures that a job that is acquired by a JobExecutor is only executed once.

Is the problem only caused by the slow execution of the sync service task? Do long-running job executions generally represent a problem for Activiti?

Thanks a lot.

Best regards,
Monte.

Outcomes