But I receive the following error, when the execute method runs:
Cannot correlate message 'Message2': No process definition or execution matches the parameters
I had done a very similar thing for sending the message from task_2 to start_2 and had no problem. I also saw this post which had a similar problem. Considering that, I marked task_5 with async-before. But I encountered the same error.
Could anyone please help me to find out the problem?
Thanks in advance
Hi @StephanHaarmann ,
Thanks a lot for your quick reply.
I had tested using async-before on task 5 and it didn’t work. But now, I tried it again and it seems working fine! Sorry, I don’t know what was the problem last time.
But I still don’t get why this async-before is needed. I saw the explanations in this forum post, but I didn’t get it very well. I guess the token in Pool_1 should arrive Task_3 before the token in Pool_2 arrives task_5. Then, there should be no problem in correlation.
I do appreciate it if you could explain it a bit, I am new in this correlation concept.
If not otherwise specified, Camunda 7 uses waiting states as transaction boundaries. These waiting states exist everywhere, where the engine has to wait for something. Examples are user tasks and most catching events.
With this behavior, Camunda 7 does as much work as possible in one transaction. This improves throughput, but is not always enough. Your process is an example for the limitation:
By default, the first transaction spans from Start to Task_1 the second transaction from Task_1 via Task_2, Start 2, and Task_5 to the end event of Pool_2. The job executor only enables Task_3 after Pool_2 completed. This is impossible because task_5 requires that task_3 is enabled. We have a cyclic dependency.
In other words, Camunda 7 processes tasks in the order that they occur: When Task_2 is executed and Message1 is sent, the transaction continues with Pool_2. Task_2 is active until Pool_2 reaches a transaction boundary. By setting async before we manually add such a transaction boundary. Once Pool_2 reaches the transaction boundary, Camunda knows that Message1 was successfully processed and Task_2 completes. Task_3 is reached (wait state) and the transaction committed.
Camunda’s transaction handling is not trivial and requires some experience. You can read more about it in our documentation:
Furthermore, I recommend following our best practices for setting transaction boundaries:
Finally, there exists a modeler plugin that visualizes transaction boundaries: