I noticed that is I’m not marking any async before\after checkboxes, method startProcessInstanceByKey completes when actual process definition is completed, however I would like my service tasks to run concurrently so I’m marking them as async
Now when running method startProcessInstanceByKey it finishes immediately and whole process is continues.
I want to be able to wait until whole process will finish and then continue with my code execution. How can I achieve that behavior?
Thanks for the answer
My goal is to run process above from my java code and wait until it completes however now method startProcessInstanceByKey returns immediately and I don’t know when process actually completes.
If I understand correct, there is no true concurrency when using parallel gateway? My ServiceTask can take a while (up to 20 minutes) so I would like to run both tasks in parallel. Is this any solution for this case?
If you want to continue the execution of your “main” program only after the process is complete, and the process has an async point, the you have to implement busy waiting in the main program. I.e. you should have a loop and periodically check the state of the process. You get the process id as the result of the start call. This is how camunda engine works. Synchronous execution only takes place until the first job in the process is finished.
Thanks @fml2 is there any example code for this in git? What I understand is I have to keep polling in my application thread to check the process instance is completed or not? I am using Spring boot camunda , how will i check that? any method that provides this in runtimeservice?
You’ll probably have to use the history service and query for the process instance with the id you got when you started the process. When the property isEnded (I’m not sure the name is correct) becomes true it means that the process is completed.