DEV Community

Cover image for Zeebe Message Correlation Java
mahfuzulamin
mahfuzulamin

Posted on

1

Zeebe Message Correlation Java

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 https://github.com/mahfuzulamin/zeebe-message-correlation-java

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay