Hello, I am using two service tasks inside parallel gateways. Ideally they should execute in parallel, but they are not. 1st Service Task sleeps for 5s and only after that 2nd Service Task executes.
After that, I ticked ‘Async Before’ and unticked ‘Exclusive’ on both the Service Tasks. This resulted in parallel execution but problem with this is, API response is returned immediately before even complete execution of BPMN (since this camunda bpmn file was triggered on hitting a rest end-point).
I need help with the implementation where all the service tasks can be executed in parallel (to improve performance in my project) and REST API endpoint should return the response only when BPMN file is executed completely.
usually concurrent execution should be possible with your configuration. You already marked both service tasks with “Async before” and “Non-exclusive”. The default job exeutor will then use a threadpool to execute all your jobs.
I just tried to reproduce your behaviour but I was able to have parallel execution in a testcase. Keep in mind to activate the automatic job execution when using the camunda process engine extension or rule (depending on JUnit 4 or 5).
Another approach you could try would be to involve External Tasks, to let the tasks decide in what manner they will be executed.
At the end of the question you mentioned that you want your REST API to only return when execution was finished. The process start call will return on approaching the parallel gateway. So you would need to wait for finishing by polling or try to implement a process end listener.
I support this, but only the first part. IMO a process listener (how would the solution look like exactly?) does not help implementing a synchronous process behaviour (as seen in the implementation of the rest end point).
you are totally correct. The second option only helps to react to the process end but does not work if you require a synchronous solution as the author mentioned in his initial post. Thank for you making this clearer.