org.activiti.engine.ActivitiOptimisticLockingException: JobEntity
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2015 05:54 PM
Hi all,
I have 2 Activiti (v5.18) engines instances pointed to the same database. I have a java delegate serviceTask that has async='true'. The java delegate is straighforward as it just inserts a row to an application table. When I test will higher message count, I see this exception below.
I understand the async step creates a job and the job is executed on a separate thread, but this is causing duplicate insertions into the app table. For example when I test with 50 messages, I see this exception in the log and sometimes 62 rows in the app table. The count on the ACT_HI_PROCINST is still 50 though. Can someone please explain what is going on and how to handle this?
Thanks
Clement
I have 2 Activiti (v5.18) engines instances pointed to the same database. I have a java delegate serviceTask that has async='true'. The java delegate is straighforward as it just inserts a row to an application table. When I test will higher message count, I see this exception below.
org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=45926] was updated by another transaction concurrently at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:294) at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:921) at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:887) at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:612) at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211) at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:137) at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66) at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:69) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
I understand the async step creates a job and the job is executed on a separate thread, but this is causing duplicate insertions into the app table. For example when I test with 50 messages, I see this exception in the log and sometimes 62 rows in the app table. The count on the ACT_HI_PROCINST is still 50 though. Can someone please explain what is going on and how to handle this?
Thanks
Clement
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 01:19 PM
That probably means the javadelegate logic you have is not transactional?
When an exception occurs, Activiti does a roll back of the transaction, if your jdbc code is not part of that transaction, then it doesn't know it has to roll back.
When an exception occurs, Activiti does a roll back of the transaction, if your jdbc code is not part of that transaction, then it doesn't know it has to roll back.
