AnsweredAssumed Answered

Async service task is tried to be run several times

Question asked by serid on Oct 26, 2016
Latest reply on Oct 26, 2016 by serid
Hi All,

I noticed that if I have an async (exclusive) task (service task) which runs for a long time activiti tries to run it several times.
So I tried to see what is happening and these are my guesses:

1) When a task is defined as async and run, it adds records to act_ru_execution and act_ru_job tables
2) The act_ru_execution table's entry has a LOCK_TIME_ populated which seems to be 5 mins ahead of the start of the task
3) The act_ru_job  table's entry has DUEDATE_ populated with the exact time as LOCK_TIME_
4) When that specified in both table's time is passing, it tries to run the job again (while the job which was first time triggered is still running)
5) I have my own logic that does not allow to run a task which is already running and throws exception

So my understanding is that when a task is defined as async and is run, it adds an entry in act_ru_execution  and act_ru_job.
Then a thread from a pool picks it up and "locks" it by updating LOCK_TIME_ and DUEDATE_ ?
And if the task does not complete in that time it releases the lock (update again) so another thread can pick it up and start again ?

Could someone clarify this for me please ?
Why such behaviour - I expect it to be the right behaviour but I would like to know the reasons behind it ?
I also found out this param:

asyncExecutorAsyncJobLockTimeInMillis: The amount of time (in milliseconds) an async job is locked when acquired by the async executor. During this period of time, no other async executor will try to acquire and lock this job. And behold the default is 5 min!

Basically I want to have the possibility to run either non async and async tasks only once until they finish / throw exception.

Many thanks,
Adrian

Outcomes