If you come from Camunda Platform, Zeebe uses the “external worker pattern”. That means that no worker code executes in the broker - it is all executed in your external workers. But what if you want to execute logic and mutations in another external system(s) - connected to Zeebe by NiFi, RabbitMQ, or some other queueing / eventing system?
How do you decompose the poll / complete lifecycle of a Zeebe job across a worker and another external system? Here is the pattern, which I call the “Decoupled Job Completion” pattern:
Josh Wulf: Here is the complete round-trip in one place:
- Workflow instance is started via
publishMessage
orcreateWorkflowInstance
- BPMN flow enters task node.
- Zeebe worker fetches job for this task-type from the engine, and constructs request, appending the Zeebe Job Id for eventual correlation at completion.
- Zeebe worker publishes message to the appropriate RabbitMQ req/command channel.
- Remote service/subscriber picks up relevant message from RabbitMQ req/command channel and processes request.
- Remote service publishes response to RabbitMQ res channel.
- RabbitMQ worker picks up response (which has Zeebe Job Id for correlation) and completes job in Zeebe (“Zeebe fulfiller”). Optionally, publish a message with a correlation value to model the service return state in your BPMN using event-based gateways. Use a standardised pattern for this to keep the adapter layer generic.
- Zeebe engine moves on to next BPMN node.
- Repeat from step 2 until done.
Below the two approaches described in step 7 are modeled. In the top one, the worker completes the job, and the external system responds by publishing a message. In the bottom one, the worker activates the job (and ends with job.forward()
in the Node client, or void in the Java client), and the external system executes the CompleteJob
command to close the loop.
See also:
Note: This post was generated by Slack Archivist from a conversation in the Zeebe Slack, a source of valuable discussions on Zeebe (get an invite). Someone in the Slack thought this was worth sharing!
If this post answered a question for you, hit the Like button - we use that to assess which posts to put into docs.