I have concurrency issues in my camunda setup.
I have a simple process with three service tasks. For debugging puropses, the tasks both refer the same class which implements a dummy method which simply makes the thread sleep 10 seconds.
When I start multiple instances of this process, they are all “stuck” on the first task. My debuging output tells me, that one Job at a time is executing the dummy task and proceeds with the remaining two tasks until it is done. When the first jobis done, the second one is executing each task.
The desired behaviour would be the parallel execution of all the startet Jobs.
My setup:
I am running a spring-boot project with the camunda spring boot starter.
What did i possibly do wrong? Is there a way to configure this behaviour?
thanks for your quick reply.
Setting the tasks to non exclusive had some effect but didn’t solve my problem.
Assuming, every task prints the process id, the current task name and counts to 3.
The original output was:
Your log output does not prove your point since it does not say which things run in parallel. Perhaps you should log start and end times of your activities or obtain that from the historic activity instances table. That should give a clearer picture. It could also be helpful if you could put your code and process up on github.
On a somewhat related side note: Job execution works with a threadpool. If all execution threads are currently executing activities (e.g. because they are all sleeping), other activities won’t be processed. The default setting is more than three, though.
That means, you deploy the process model and Java code as part of a process application to a distribution you downloaded from camunda.org? Never mind, you use Spring Boot Starter.
Nov 10, 2016 5:42:47 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 8 task: Task1 count: 1
Nov 10, 2016 5:42:47 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 12 task: Task1 count: 1
Nov 10, 2016 5:42:47 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 16 task: Task1 count: 1
Nov 10, 2016 5:42:48 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 12 task: Task1 count: 2
Nov 10, 2016 5:42:48 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 16 task: Task1 count: 2
Nov 10, 2016 5:42:48 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 8 task: Task1 count: 2
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 8 task: Task1 count: 3
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 12 task: Task1 count: 3
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 16 task: Task1 count: 3
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Ending process 8 task Task1 Thu Nov 10 17:42:49 CET 2016
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Ending process 12 task Task1 Thu Nov 10 17:42:49 CET 2016
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Ending process 16 task Task1 Thu Nov 10 17:42:49 CET 2016
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Starting process 12 task Task2 Thu Nov 10 17:42:49 CET 2016
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Starting process 8 task Task2 Thu Nov 10 17:42:49 CET 2016
Nov 10, 2016 5:42:49 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Starting process 16 task Task2 Thu Nov 10 17:42:49 CET 2016
Nov 10, 2016 5:42:50 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 12 task: Task2 count: 1
Nov 10, 2016 5:42:50 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 16 task: Task2 count: 1
Nov 10, 2016 5:42:50 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 8 task: Task2 count: 1
Nov 10, 2016 5:42:51 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 12 task: Task2 count: 2
Nov 10, 2016 5:42:51 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 8 task: Task2 count: 2
Nov 10, 2016 5:42:51 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 16 task: Task2 count: 2
Nov 10, 2016 5:42:52 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 12 task: Task2 count: 3
Nov 10, 2016 5:42:52 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Ending process 12 task Task2 Thu Nov 10 17:42:52 CET 2016
Nov 10, 2016 5:42:52 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 16 task: Task2 count: 3
Nov 10, 2016 5:42:52 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: Ending process 16 task Task2 Thu Nov 10 17:42:52 CET 2016
Nov 10, 2016 5:42:52 PM org.slf4j.impl.JCLLoggerAdapter info
INFORMATION: process: 8 task: Task2 count: 3
This indicates true parallel execution and is similar to your expected pattern, if I understand it correctly. So I guess something in your engine setup is not correct, however I am not familiar with the Spring Boot starter and couldn’t find anyhting on a quick glance. Perhaps @jangalinski, maintainer of the extension, can help us out.
Seems like the DefaultJobConfiguration initializes a ThreadPoolTaskExecutor with default poolSize=1. That would mean although execution is async, due to the pool size the execution is sequential.
You can overwrite the TaskExecutor by providing an additional TaskExecutor Bean.
At least theoretically - I tried to do so on the current 2.0.0-SNAPSHOT but get a failure. Please try it out and report an issue if you do not succeed.