Now i am using ParallelGateway,For different fork branches,I use the Thread.currentThread().getName() method to get the thread name of each branch. They are the same when I don’t use asynchronous continuation.
@flybird have you set the property exclusive=true?
hello thank you for your reply.
when I didn’t set up asynchronous continuation.Different fork branches are executed by the same thread，
Because the thread names are the same。Is the different sub-execution of the ParallelGateway handled by the same thread? How can we improve efficiency in this way?
yes,When I set asyncAfter = true or asyncBefore=true, I set up the attribute Exclusive = true,
And the subsequent process is executed by another thread
@flybird, if i understood correctly, even the parallel gateway works synchronous fashion, unless if it marked for asynchronous continuations.
In synchronous execution, by default, the process engine uses the client thread to do work, so it will be executed by same thread.
If you want to achieve parallelism you have to mark it for asynchronous execution which will delegate the execution to the job workers in the Job executors thread pool.
Client-Service interactions can be designed as below strategies:
- Request/Response (synchronous execution)
- Request/Acknowledge (asynchronous execution)
2. Request/Acknowledge/Callback or Request/Acknowledge/Relay
So you can decide how the service need to be invoked.
@aravindhrsThank you for your answer.
My process does not need to be executed asynchronously
I understand your interpretation of JobExecutor,
If I want to achieve parallelism
Which one needs to set the asynchronous continuation?
1、Just on the ParallelGateway
2、On a delegate or script of the SubExecution
@aravindhrs Thank you very much,
I got what I want to know.
Another problem is that JobExecutor is sometimes slow or even never executed when executing a job.What is the reason for this？And how to troubleshoot it?
@flybird the activity should be marked as asyncbefore/asynafter =true & jobExecutorActivate=true(process engine config) should be enabled.
@flybird consider point 2 and in point 1 asynchronous continuation should be set to join parallel gateway for synchronization to avoid the optimistic locking exception
After the test is indeed like this
I understand what you mean.
But I can’t find the location to set the jobExecutorActivate property. I guess there should be some xml in the bpmn source code, maybe “process.xml” or “bpm-platform.xml”. If you can specify the location, I will be very grateful
Its in bpm-platform.xml and you need to set that property int this
check this for your reference: bpm-platform.xml | docs.camunda.org
The version of Camunda we are currently using is v7.10.0. The work of integrating camunda with spring boot is done by an open source organization. As a user, we can see through the log that JobExecutor has been started, does it mean that the jobExecutorActivate property has been set to True? in this case, the above problem has occurred.
@flybird can you upload your bpmn file?
jobExecutorActivate property has been set to True by default.
Thank you for your reply
Sorry, I can’t upload related files for other reasons.
When I am in debug, there is an execute method in a class named ExecuteJobsCmd, It queried a job in database according to the jobId attribute. When my process is stuck, the job in the database exists, but the breakpoint information Show that the job is null, and after about five minutes, the job was found and the process can be completed successfully.
Why is this？？？
The general flow is, I have three BPMN files, bpmn1, bpmn2, bpmn3. In bpmn3, there is a subProcess configured with AsyncAfter = true and Exclusive = true. This subProcess is mainly composed of an IntermediateCatchEvent and receives the message of the WebService service. Bpmn3 is called as CallActivity element by bpmn2, bpmn2 is called as CallActivity element bpmn1. In bpmn1, I use parallel gateway, and each fork branch will call bpmn2.The stuck phenomenon is what happens in this situation.
I assume that, in bpmn 1, after parallel gateway split you have two call activity, one will call bpmn2. What about another call activity after the parallel split gateway? calling same bpmn2?
Yes, as you said
@flybird I don’t think it was a best practice to call same process definitions in both the parallel tasks.
Although, Exclusive = true at the activity makes sequential execution by the same thread.
To acheive concurrency, set asyncBefore=true && Exclusive=false to both of the parallel tasks and the parallel join gateway should be marked as asyncBefore=true & Exclusive = true for synchronizing the state.
Thank you for your suggestion.
But based on this scenario, I designed several simple demos. For example, each branch after the concurrent gateway calls a different subprocess. This subProcess sets AsyncAfter=true and Exclusive=true, and the stuck phenomenon can also occur.
Although, Exclusive = true at the activity makes sequential execution by the same thread , in that case parallel join gateway should be marked as asyncBefore=true for synchronizing the state.
I will try your suggestion, thank you very much for your answer,