cancel
Showing results for 
Search instead for 
Did you mean: 

ParallelGateway for Service Task

lojian
Champ in-the-making
Champ in-the-making
As we know that ParallelGateway could fork all outgoing sequence flows, create one concurrent execution for each sequence flow.
My question here is, ”concurrent" here means "each flow is running in different thread" ?
17 REPLIES 17

actuser
Champ in-the-making
Champ in-the-making
Hi Tijs,
Is it still planned to include this patch in the 5.9 release ?  From a preliminary test using the trunk code it seems that it is still not possible to successfully run multiple "asynchronous continuations" in their own separate thread in the parallel gateway. 
Regards..
John

trademak
Star Contributor
Star Contributor
Hi John,

Yes this should be possible in the 5.9 release. Can you share a test that doesn't work as it's supposed to?

Best regards,

actuser
Champ in-the-making
Champ in-the-making
Hi Tijs,
I will check this with the developer.  The initial test showed that the 'Asynchronous' tasks on the Gateway executed successfully, but they executed "in-sequence" rather than concurrently. He said that the same thread was reused for each  task execution, so maybe it was a configuration problem in our test.
I will come back to you on this…
Cheers.
John

actuser
Champ in-the-making
Champ in-the-making
Hi Tijs,
Does the threading behaviour differ when using the "StandaloneInMemProcessEngineConfiguration" ?   In this test the same thread from the thread-pool is used to execute the 'asynchronous continuation' task logic (just a system.out), so they execute in sequence. This is the same behaviour as for 'synchronous' tasks.
Just to clarify - should the patch allow the running of "Asynchronous Continuation" tasks on a gateway in their own separate thread ? So we should see multiple threads running concurrently in the gateway ?

/John.

guy_gavriely
Champ in-the-making
Champ in-the-making
5.9 is in two weeks, so I guess this feature should be included already, can someone confirm? I've checked out the code but still not sure if its there.
Thanks,
Guy

feecon
Champ in-the-making
Champ in-the-making
Hi,

I get the latest snapshot of Activiti 5.9, and I run sucessfully some workflow with asynchronous tasks and parallel gateway.
However when I grow up the bench by starting 1000 workflows with the same ProcessEngine and changing the size of the thread pool size to 1024 (min = max = queuesize) in the DefaultJobExecutor class, I get some racing exceptions:

SEVERE: Error while closing command context
java.lang.NullPointerException
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:34)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:77)
at org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:35)
at org.activiti.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:78)
at org.activiti.engine.impl.persistence.entity.MessageEntity.execute(MessageEntity.java:29)
at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:67)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:46)
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:619)


And some times:

SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: No job found with id '3323'
at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:58)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:46)
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:619)

I guess this exceptions don't appear with the default configuration because there are only 10 threads running concurrently.
Are you aware of this issues ?
Thanks

feecon
Champ in-the-making
Champ in-the-making
I try to minimize an unit test to reproduce these previous exceptions.
You can change variables NB_PARALLEL_WORKFLOWS and threadPoolSize.

Hoping it can help…

falko_menge
Champ in-the-making
Champ in-the-making
no limitations besides maybe the number of concurrent job executors?
You're right. The number of Job Executor theads limits the number of jobs executed in parallel.

Does the threading behaviour differ when using the "StandaloneInMemProcessEngineConfiguration" ?
No.

I try to minimize an unit test to reproduce these previous exceptions.
Your tasks have not set activiti:exclusive="false". Hence, one JobExecutor thread will execute all jobs sequentially:
Since activiti 5.9, the JobExecutor makes sure that jobs from a single process instance are never executed concurrently.
[…]
All asynchronous continuations and timer events are thus exclusive by default. In addition, if you want a job to be non-exclusive, you can configure it as such using activiti:exclusive="false".
See also: Activiti Userguide: Exclusive Jobs

However, this doesn't explain the exceptions you got.