Camunda execution exercises
As you learned in Camunda basics for execution, Zeebe Play makes it possible to execute and complete BPMN processes with service tasks even before those tasks have been implemented. Practice more of that to become truly familiar with
service task configuration
input and output mapping expressions
exclusive gateway path condition expressions
process deployments
process instances
completing processes using Zeebe Play.
Eventually you’ll iterate enough to also learn configuration of multi-instance tasks.
Sole service task
Let’s start with simple:
Model a process with just a single service task.
Give the process Name and ID that you can recognize from Zeebe Play user interface.
Deploy process to Zeebe, start an instance of it and complete its service task as shown in the chapter Execute with Zeebe Play.
Add exclusive gateway
And then dive straight to the deep end…
Re-use the model from the previous exercise.
Add exclusive gateway after the sole service task and split the flow with a path to an alternative end event: Work not completed.
Add local variable
completed
with FEEL expressionfalse
into service task Inputs.Add process variable
workCompleted
with FEEL expressioncompleted
into service task Outputs. (You may check chapter Feel expressions on how it evaluates local variable back into process scope.)Add FEEL expression
workCompleted
as condition for the path from the exclusive gateway to the original end event.From the element context modeling palette, make the new path to the new end event the Default Flow.
Deploy process to Zeebe, start two instances of it and complete their service tasks properly with variables as shown in the chapter Execute with Zeebe Play to reach both end events (in separate instances, of course).
Handle BPMN error
Let’s then refactor a little and add a new feature:
Re-use the model from the previous exercise.
Remove end event Work not completed and route the path to path back to the service task instead.
Add a error boundary event to service task with a path to a new Work abandoned.
Configure the error boundary event to expect error with some specific error code.
Deploy process to Zeebe, start an instance of it and Throw Error with the code you just configured on its service task to reach the new end event Work abandoned.
Embedded sub-process wrapping
This iteration should not change any behavior of the process, but would make the model ready for multi-instance:
Re-use the model from the previous exercise.
Add Expanded SubProcess and drag everything else in the process inside it.
Add new start event Work requested to lead the flow into the sub-process.
Add new end event Request completed to end the process after sub-process.
Deploy process to Zeebe and start enough instances of it to test with Zeebe Play that all the previous features of the process remain.
Multi-instance sub-process
Work often comes in batches, and BPMN supports that with multi-instance. An single BPMN element or even a complete embedded sub-process can be configured to be multi-instance, causing every item in a collection to be given its own instance of the element or sub-process. Let’s make your freshly refactored sub-process to work over a collection:
Re-use the model from the previous exercise.
Add new service task Get work items between the main start event and the sub-process.
Add local variable
results
with FEEL expression[]
into service task Inputs and process variableworkItems
with FEEL expressionresults
into service task Outputs.Toggle sequential multi-instance on the embedded sub-process
Configure multi-instance properties on the sub-process as following:
Input collection:
workItems
Input element:
workItem
Output collection:
workItemsCompleted
Output element:
workCompleted
Add local variable
ẁorkCompleted
with FEEL expressionfalse
into the sub-process’ Inputs to ensure it remain in sub-process’ scope.Deploy process to Zeebe, start an instances of it, open it at Zeebe Play, complete the first service task with variables
{"results": [null, null, null]}
, continue to complete the process and, eventually, confirm that it ends withworkItemsCompleted
process variable having meaningful result.
multi-instance-subprocess-with-timer.bpmn