cancel
Showing results for 
Search instead for 
Did you mean: 

OptimisticLocking exception when try to update execution-variable

shreyashp
Champ in-the-making
Champ in-the-making
Hi,
I have setup a spring activiti engine.
I do a ProcessEngines.getDefaultProcessEngine(), will i get the same spring engine instance ?
How many job-executors will i have ? (i have my default job-executor turned on in config, async-executor is off)

Now the issue:
I startProceInstanceByKey(), and set a variable named 'envelop' in variableMap.
I have a process which has a service task.
1. This service task delegate (of type TaskActivityBehavior) puts a JMS message on ActiveMQ and a MessageListener reads it and makes REST call to external service.
2. The external service returns response via an REST end point in my system.
3. During this time my service task is waiting for a signal.
4. I am trying to update the value of variable 'envelop' with response received from external service. I use ProcessEngines.getDefaultProcessEngine().getRuntimeService().setVariable("envelop",newValue);
5. I signal the waiting serviceTask using the stored executionID. I use ProcessEngines.getDefaultProcessEngine().getRuntimeService().signal(envelop.getExecutionId());

I ran above process to spawn 100 processInstances. Out of which 96 succeeded, but 4 failed.
All four had same reason. In Step 4 above, while updating the execution variable it throws OptimisticLocking error as below:
org.activiti.engine.ActivitiOptimisticLockingException: ByteArrayEntity[id=290, name=var-envelop, size=335] was updated by another transaction concurrently.

Kindly help, my envelop variable is associated with different executionID, there is no case where someone else will update it in another transaction.
3 REPLIES 3

shreyashp
Champ in-the-making
Champ in-the-making
StackTrace:
org.activiti.engine.ActivitiOptimisticLockingException: ByteArrayEntity[id=592, name=var-envelop, size=335] was updated by another transaction concurrently
at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:875)
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:614)
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212)
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:138)
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.RuntimeServiceImpl.setVariable(RuntimeServiceImpl.java:186)

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

could you reproduce the issue in the jUnit test please?

https://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin

jbarrez
Star Contributor
Star Contributor
About your questions:

"I do a ProcessEngines.getDefaultProcessEngine(), will i get the same spring engine instance ?"

Yes. It will return the same ProcessEngine instance.

"How many job-executors will i have ? (i have my default job-executor turned on in config, async-executor is off)"

One. The 'old' job executor will be used (async executor is the new one).
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.