We could not find any clear working example of Zeebe message correlation when we needed to implement it. After trying different things we have figured out how it works. This project simulates packaging multiple items in a order with message correlation where order id is the unique key.
The workflow BPMN: The BPMN file is included in the resources of the github project.
For single item the bottom flow gets executed based on the condition.
For multiple items message gets correlated in “Collect Items” Receive Task and collected item count gets incremented upon receiving a new message. It runs through the loop at the top the diagram until total number of items are received. This is implemented in the PackageItemsJobHandler of this Java project.
Timeout is implemented so that it doesn’t wait in the loop forever if next messages are not sent. In this project 5 minutes is passed as timeout to Zeeke workflow. Interrupting timer boundary event is included to timeout after a duration which is provided as expression by accessing a variable.
The complete project is available on github https://github.com/mahfuzulamin/zeebe-message-correlation-java
Top comments (0)