DEV Community

Cover image for Zeebe Message Correlation Java

Zeebe Message Correlation Java

Experienced Software Engineer who loves work Java, J2EE and related technologies. I have worked with other languages like JavaScript, Python, C#, ASP.Net and Objective C.
・1 min read

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.
    Alt Text

  • For single item the bottom flow gets executed based on the condition.
    Alt Text

  • 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
    Alt Text

  • Workflow instance with 2 items to package is
    Alt Text

  • 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.
    Alt Text

The complete project is available on github

Discussion (0)