cancel
Showing results for 
Search instead for 
Did you mean: 

How to control the frequency at which ACT_RU_JOB table is being polled

rajeshiv
Champ in-the-making
Champ in-the-making

Hi,
I have a work flow with an expiration timer set on it. I see that the activiti polls on the ACT_RU_JOB. I see that the below two queries are being executed every time it polls.

select *
from ACT_RU_JOB
where (RETRIES_ > 0) and (DUEDATE_ is null or DUEDATE_ < :1) and (LOCK_OWNER_ is null or LOCK_EXP_TIME_ < :2) and (RETRIES_ > 0)
SQL Details: 3mwmj7bu8yw9w

select *
from ACT_RU_JOB
where (TYPE_ = 'timer') and (DUEDATE_ is not null) and (DUEDATE_ < :1) and (LOCK_OWNER_ is null or LOCK_EXP_TIME_ < :2) and (RETRIES_ > 0) order by DUEDATE_

However I have large number of records in those tables and because activiti is polling I see that the above two queries are executing thousand of times in a soan of 15 mins. This is causing about 80% of my CPU time. Is there a way to manage the time interval at which activiti will poll for these tabels? what do you suggest so that these queries are not executed that frequently ?

Your advise is highly appreciated .
Thanks in advance !!!
Regards
Rajesh
8 REPLIES 8

jbarrez
Star Contributor
Star Contributor
Which Activiti version? I'm assuming the latest: then those settings can be tweaked: https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/...

sridhar_b
Champ in-the-making
Champ in-the-making
Thanks jbarrez.

Which are the ones below need to be tweaked?  Is it possible to disable the polling?

keepAliveTime = 5000L;
maxTimerJobsPerAcquisition = 1;
maxAsyncJobsDuePerAcquisition = 1;
defaultTimerJobAcquireWaitTimeInMillis = 10 * 1000;
defaultAsyncJobAcquireWaitTimeInMillis = 10 * 1000;
timerLockTimeInMillis = 5 * 60 * 1000;
asyncJobLockTimeInMillis = 5 * 60 * 1000;
retryWaitTimeInMillis = 500;

sridhar_b
Champ in-the-making
Champ in-the-making
I'm currently using 5.12 version. Is there a way to fix this in ver 5.12?
Thanks in advance.

jbarrez
Star Contributor
Star Contributor
"Is it possible to disable the polling?"

Yes, simply disable the job executor (or the asyncExecutor) on the process engine configuration.

"Which are the ones below need to be tweaked"

The acquireWaitTimeMillis are the ones used to configure the frequency of polling

"I'm currently using 5.12 version. Is there a way to fix this in ver 5.12?"

No idea anymore. 5.12 is 2,5 years old. That's ancient in software country …

sridhar_b
Champ in-the-making
Champ in-the-making
Thanks jbarrez. Appreciate you quick response.

sridhar_b
Champ in-the-making
Champ in-the-making
Hi jbarrez,

I have reduced the frequency at which these queries are executed by tweaking the setting in activiti.cfg.xml.
I un-commented the below in activity.cfg.xml to use the DefaultJobExecutor.
Also, added the property "waitTimeInMillis" to the bean and set its value to 10min.

With the above change, I am able to control the frequency of the query execution, however, I see the Retry is not functioning correctly.
I have a timer with delay of 5min between each Retry. After the first execution, it retries next 2 executions immediately and doesn't wait for the timer.

However, when I comment back the below code, it works fine. It does wait between each Retry. Please let me know if I need to do it differently.
Thanks in advance.

//Comment the block
<property name="jobExecutor">
                        <bean class="org.activiti.engine.impl.jobexecutor.DefaultJobExecutor">
                                <property name="queueSize" value="3"/>
                                <property name="corePoolSize" value="3"/>
                                <property name="maxPoolSize" value="10"/>
                                <property name="maxJobsPerAcquisition" value="30"/>
                                <property name="waitTimeInMillis" value="600000"/>
                        </bean>
</property>

sridhar_b
Champ in-the-making
Champ in-the-making
Hi jbarrez,

I have reduced the frequency at which these queries are executed by tweaking the setting in activiti.cfg.xml.
I un-commented the below in activity.cfg.xml to use the DefaultJobExecutor.
Also, added the property "waitTimeInMillis" to the bean and set its value to 10min.

With the above change, I am able to control the frequency of the query execution, however, I see the Retry is not functioning correctly.
I have a timer with delay of 5min between each Retry. After the first execution, it retries next 2 executions immediately and doesn't wait for the timer.

However, when I comment back the below code, it works fine. It does wait between each Retry. Please let me know if I need to do it differently.
Thanks in advance.

//Comment the block
<property name="jobExecutor">
                        <bean class="org.activiti.engine.impl.jobexecutor.DefaultJobExecutor">
                                <property name="queueSize" value="3"/>
                                <property name="corePoolSize" value="3"/>
                                <property name="maxPoolSize" value="10"/>
                                <property name="maxJobsPerAcquisition" value="30"/>
                                <property name="waitTimeInMillis" value="600000"/>
                        </bean>
</property>

jbarrez
Star Contributor
Star Contributor
"After the first execution, it retries next 2 executions immediately and doesn't wait for the timer."

I'm not sure I'm following what you are saying here. What do you mean with 'wait for the timer'? The settings above normally don't influence the retry (as the retry is done when the job is executed, while the settings above are for acquisition).

Also note that setting it to 10 minutes won't be picking up timers that are set to 5 minutes difference ..