AnsweredAssumed Answered

Concurrency exception on timer event

Question asked by tstephen on Aug 22, 2011
Latest reply on Aug 22, 2011 by ronald.van.kuijk
Hi,

I have found that the time taken to start a process instance can be too long for my purposes when the process definition includes relatively slow (hundreds of milliseconds) activities immediately after the start event.

In order to force Activiti to return immediately after starting the process I have put a timer event as the first task with a very short (1 second) timeout. In unit tests this achieves my goal of a faster process start but in the tomcat environment I am seeing the following stack trace.

I have two questions:
1. is there a better way to ensure the fastest possible process start? It seems like it would be good to have an Activiti flag to persist the process for async handling, does such a thing exist?
2. Any ideas how to avoid the Job thread hitting this concurrency exception? I'd prefer to avoid simply trying longer delays in the timer event until it works  ;)

Thanks, Tim
SEVERE: Error while closing command context
org.activiti.engine.ActivitiOptimisticLockingException: TimerEntity[62760] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:425)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:338)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:147)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:103)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.jobexecutor.JobAcquisitionThread.run(JobAcquisitionThread.java:63)

Outcomes