Zeebe Message Correlation Java Example

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.

  • Message correlation workflow setting in the BPMN file

  • 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 GitHub - mahfuzulamin/zeebe-message-correlation-java: This is a Java implementation of message correlation on Zeebe.


The forum was not allowing me to embed multiple images as I am a new user. That’s why I am uploading other screenshots in the comment.

1 Like
1 Like
1 Like

Hi @mahfuz,

thank you for sharing this example :+1:

And welcome to the community :tada: