We are using the callActivity in our project and we have faced the following issue(sorry I do not have diagram):
We out the callActivity element, and configured it to run in parallel, in our diagram and we expected to:
Each item to be processed in parallel of the others
The result was, the first two items were processes in parallel and the other were synchronized.
Example execution(the collection of the items is a list of ints starting from 1 to N, each sub-process prints the integer as the process is started):
We saw 1 or 2 produced on the output(the order is undetermined because the first two are executed in parallel)
Then, we see 3, 4, 5, 6, … N
That lead me to the thought that this could a problem.
Could you tell me whether there is some problem in the callActivity?
If you set the multi instance element to run in parallel, this means that there will be multiple call activities started without waiting for the other ones to finish first (like it would be the case with sequential). So it’s not parallel on a thread level. If you want real parallel behaviour with multiple threads executing the call activities at the same time, then the first step in the sub process that is started with the call activity should be async. Then you will see multiple sub processes being executed at the same time.
Thanks for the responses.
Martin, we have configured our jobExecutor to support asynchronous executions.
Tijs, the configuration which you described is in place…
Also, I want to mention something more. I have seen an OptimisticLockingException which is caused during the execution of the sub-processes.
Have you seen something like that before?
Optimistic locking exception is thrown when object (e.g. process, case) update was not performed. It means that object’s revision was already changed and update was referencing wrong object revision.
Yes, I understand the OptimisticLockingException but the problem is that it is happening when I want to start >20 parallel sub-processes using CallActivity.
Is there some way to provide a test for this? Jira item?
I have written an unit test:
import org.flowable.engine.test.Deployment;
import org.flowable.engine.test.FlowableRule;
import org.junit.Rule;
import org.junit.Test;
public class MyUnitTest {
@Rule
public FlowableRule flowableRule = new FlowableRule();
@Test
@Deployment(resources = { "diagrams/main-process.bpmn", "diagrams/sub-process.bpmn" })
public void test() throws Exception {
flowableRule.getRuntimeService()
.startProcessInstanceByKey("mainProcess");
Thread.sleep(1000000000);
}
}
The problem is that it is not running( I cannot see the output of the processes).
The flowable.cfg.xml:
In the parallel.flowable.test.Test i have created deployment and process instance based on the diagram which is located in src/main/resources/diagrams/holiday-request.bpmn20.xml. The process instance is created successfully and I have dumped the execution for the process instance and the result is 2 executions: one is with ActivityId = null and the other one with ActivityId=approveTask and this is stuck in the while loop(The process never ends and the ActivityId is not changed - the ActivityId is always approveTask).
Could you tell me what I have done wrong?
In my team we are moving from Activiti to Flowable, please ignore if somewhere the Activiti word is mentioned
Thanks a lot for the test. I did some changes there because it did not fail. See attached patch. (If you allow me to push to your example it could be faster.)
The exception which I’ve got is :
Caused by: org.h2.jdbc.JdbcSQLException:
Deadlock detected. The current transaction was rolled back. Details: "
Session #4 (user: SA) is waiting to lock PUBLIC.ACT_RU_JOB while locking PUBLIC.ACT_RU_EXECUTION (exclusive), PUBLIC.ACT_HI_VARINST (exclusive), PUBLIC.ACT_HI_PROCINST (exclusive), PUBLIC.ACT_HI_ACTINST (exclusive), PUBLIC.ACT_RU_VARIABLE (exclusive).
Session #2 (user: SA) is waiting to lock PUBLIC.ACT_RU_EXECUTION while locking PUBLIC.ACT_RU_JOB (exclusive)."; SQL statement:
insert into ACT_RU_JOB (
Is this the error which you want to solve? (I did not find any optimistic locking exception)
BTW. I found similar test in flowable source org.flowable.engine.test.bpmn.async.AsyncTaskTest#testAsyncCallActivity
Also, yes, the error about the
Caused by: org.h2.jdbc.JdbcSQLException:
Deadlock detected. The current transaction was rolled back. Details: "
Session #4 (user: SA) is waiting to lock PUBLIC.ACT_RU_JOB while locking PUBLIC.ACT_RU_EXECUTION (exclusive), PUBLIC.ACT_HI_VARINST (exclusive), PUBLIC.ACT_HI_PROCINST (exclusive), PUBLIC.ACT_HI_ACTINST (exclusive), PUBLIC.ACT_RU_VARIABLE (exclusive).
Session #2 (user: SA) is waiting to lock PUBLIC.ACT_RU_EXECUTION while locking PUBLIC.ACT_RU_JOB (exclusive)."; SQL statement:
insert into ACT_RU_JOB (
is what I want to solve.
Thanks for the explanation.
I have added a new test in the MyTest.java class which uses the flowable.cfg.xml.
The problem is that the process is started but I cannot see any progress in it.
If you start the test, you will se a lot of nulls in the console(current ActivityId).
process instance itself does not points to activityId. There is new execution created as a child of the process instance. you can query for it and get the activityId with
The problem is that some of your Multiinstance asynchronous jobs fail because of optimistic locking exception. If job fails, a timer is created. Test waits on this timer to be finished.
But if I start a diagram which does not have CallActivity in it, the result is the same - I have a process which is not progressing at all.
Anyway, could you help me in order to resolve that? Why is this OptimisticLockingException thrown- what have caused it(or to ask, which two parallel transactions are executed against the same table at the same time)?