cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Gateway and asynchronous continuations

filipearaujo
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to create a parallel gateway with three sequence flows with destination a service task with asynchronous continuation.

But unfortunately it gives me this exception:

Oct 29, 2011 2:12:11 AM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiOptimisticLockingException: ExecutionEntity[5] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:435)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:348)
   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.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:36)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:680)
Exception in thread "pool-1-thread-2" org.activiti.engine.ActivitiOptimisticLockingException: ExecutionEntity[5] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:435)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:348)
   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.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:36)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:680)


Seems that the first servicetask runs without a problem but when the other two are executed it gives the exception. I need to execute all the 3 services task. Smiley Sad
There are any workaround to this exception?

Thank you very much.

Filipe Araújo.

I'm testing with:

- eclipse plugin 5.8
- engine 5.8
4 REPLIES 4

trademak
Star Contributor
Star Contributor
Hi,

I've just answered a post on the forum with the same exception: see http://forums.activiti.org/en/viewtopic.php?f=6&t=2596
How did you test this?

Best regards,

filipearaujo
Champ in-the-making
Champ in-the-making
Yes i've seen it, but the given solution ("retrying") it's not the solution i'm looking for. I'm testing this in the:

- eclipse plugin 5.8 (activiti.cfg.xml)
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
  <property name="databaseSchemaUpdate" value="true"/>
      <!– job executor configurations –>
  <property name="jobExecutorActivate" value="true" />
</bean>

- engine 5.8

With this workflow:

[img]http://dl.dropbox.com/u/175705/Screen%20shot%202011-10-30%20at%206.03.10%20PM.png[/img]

With A,B and C asynchronous, I want to start the 3 tasks at the same time and when the 3 finish their job, task D is executed. It's a simple example.

trademak
Star Contributor
Star Contributor
Hi,

You're right. The parallel gateway / async continuation combination seems to the problem.
We'll look into this.

Thanks,

meyerd
Champ on-the-rise
Champ on-the-rise
We lack support for exclusive jobs.

What happens is that 3 jobs are created and executed by the job executor concurrently. The job executor has a thread pool to which it delegates the actual execution of the jobs. So in this case 3 threads are going to execute one service task each. To do this, they check out the ExecutionEntity in three different transactions. Now there is a race condition: whichever of the transactions is first will be able to commit, the other ones fail.

So this is both expected and unexpected behavior: form the point of view of engine-persistence it is expected, from the point of view of the user it is maybe unexpected.

Update:
I moved the discussion about how to handle this to the developer forum:
http://forums.activiti.org/en/viewtopic.php?f=4&t=2652&start=0