Timeout behaviour in activity processing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2011 05:42 AM
in the following excerpt of our process definition
waitState (TimerBoundaryEvent = 1second) -> Service Task 1 -> Service Task 2 (> 10 minutes)->waitState
I have been observing that our chain of service tasks are being rexecuted for three times with an intervall of about 10 minutes.
I know there is a retry feature which defaults to 3 retries.
But I thought retries are only executed in case of exceptions.
Since we have a very long running service task I assume due to to some timeout feature in Activiti
our chains gets rescheduled.
Could you please clarify ?
Regards
dokmatik
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2011 09:50 AM
In the default configuration Jobs are locked in the database for 5 minutes.
If executing the job (in this case performing the transaction up to the second wait state) takes longer than 5 minutes, it will be executed again.
Look at org.activiti.engine.impl.jobexecutor.JobExecutor, property lockTimeInMs
It could also be that the job fails, then it is also retired.
I would also worry about transaction timeouts.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2013 04:23 AM
We have changed in activiti-engine.jar following fields of JobExecutor:
protected int maxJobsPerAcquisition = 0; // no retries
protected int lockTimeInMillis = 20 * 60 * 1000; // 20 min
but behaviour of activiti seems stayed as before (after 5 min retry is triggered anyway), besides we have seen that act_ru_job table contains job with lock_exp_time_ set to 20 mins as it is in code.
Do you know why is this happening?
How to increase 5 mins and set retries to 0?
Thank you.
BR
Marije
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2013 07:39 AM
public Object execute(CommandContext commandContext) {
JobEntity job = Context
.getCommandContext()
.getJobEntityManager()
.findJobById(jobId);
job.setRetries(0);
job.setLockOwner(null);
job.setLockExpirationTime(null);
if(exception != null) {
job.setExceptionMessage(exception.getMessage());
job.setExceptionStacktrace(getExceptionStacktrace());
}
}
Use a process-engine configuration with a JobExecutor set manually, and call the setLockTimeInMillis() with the value you need. Also, make sure that the transaction-timeout of your connection is AT LEAST as big as the lock-time you chose, otherwise the job will fail due to transaction-timeout.
This, in combination with the zero-retries-approach will fix your issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 08:21 AM
We are using postgres database so how we can set/change connection transaction-timeout in order to avoid those timeouts?
Thanks.
BR
Marije
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 09:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 10:11 AM
Is that possible?
Thanks,
BR
Marije
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2013 02:53 AM
For long-lasting operations (that don't explicitly need a transaction to be open), consider using a mechanism that halts the process (e.g.. with a receive-task) and do the work externally. When finished, just signal the process using the API (possibly passing any variables that need to be set as a result of the long-running operation).
If you have a lot of long-running stuff, consider using camel and activiti for this, as camel has a lot of great stuff OOTB for this kind of use cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 09:53 AM
Is it possible to configure LockTimeInMillis on serviceTask level, but not globally for the JobExecutor? We have some async service tasks that are rather long-running and during their execution they need to read/write variables to DelegateExecution. So what is the recommended approach for this use case?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 03:38 PM
"local" setting of LockTimeInMillis is not supported. (You could implement your own JobExecutor implementation).
I would create real asynch call in your case.
1. call service start (just take the request to start the execution and return immediately)
2. wait on the message/signal from the service in the process execution to proceed further.
Regards
Martin
