New to BPMN and want to learn more before moving forward? This blog post helps explain the standard and why it's a good fit for microservices orchestration.
Already familiar with BPMN and how to create a BPMN model in Camunda Modeler? Find the finished model we create during the tutorial here: Zeebe Getting Started Tutorial Process Model.
If you're using the finished model we provide rather than building your own, you can move ahead to deploy a process.
Camunda Modeler is an open-source desktop BPMN modeling application created specifically for Zeebe. This application gives developers powerful features to design and deploy automated processes, human workflows, decision tables, and decision requirement diagrams using the globally-recognized BPMN and DMN standards.
Get started with Camunda Modeler using our installation guide.
In this section, we'll use Camunda Modeler to create a process model and get it ready to be deployed to Zeebe.
We'll create an e-commerce order process as our example, and we'll model a process that consists of the following:
- Initiating a payment for an order
- Receiving a payment confirmation message from an external system
- Shipping the items in the order with or without insurance depending on order value
This is what your process model will look like when we're finished:
The payment task and shipping tasks are carried out by worker services we'll connect to the workflow engine. The Payment Received message is published to Zeebe by an external system, and Zeebe correlates the message to a process instance.
To get started, take the following steps:
- Open Camunda Modeler and create a new BPMN diagram.
- Save the model as
order-process.bpmnin the top level of the Zeebe broker directory you just downloaded. As a reminder, this directory is called
The first element in your model is a start event, which should already be on the canvas when you open Modeler.
- It's a BPMN best practice to label all elements in our model, so double-click the start event and label it
Order Placedto signify that our process is initiated whenever a customer places an order.
Next, we need to add a service task. Take the following steps:
- Click on the start event and select the task icon.
- Label the newly-created task Initiate Payment.
- Click the wrench icon and change the task to a service task.
Next, we'll configure the Initiate Payment service task so an external microservice can work on it. Take the following steps:
- Click on the Initiate Payment task.
- Expand the Properties panel on the right side of the screen if it's not already visible.
- In the Type field in the Properties panel, enter
This is what you should see in your Modeler:
This Type field represents the job type in Zeebe.
See a few concepts important to understand at this point below:
- A job is simply a work item in a process that must be completed before a process instance can proceed to the next step. (See: Job Workers)
- A process instance is one running instance of a process model. In our case, this is an individual order to be fulfilled. (See: Processes)
For every process instance that arrives at the Initiate Payment service task, Zeebe creates a job with type
initiate-payment. The external worker service responsible for payment processing (the so-called job worker) polls Zeebe intermittently to ask if any jobs of type
initiate-payment are available.
If a job is available for a given process instance, the worker activates it, completes it, and notifies Zeebe. Zeebe then advances that process instance to the next step in the process.
Next, we'll add a message event to the process. Take the following steps:
- Click on the Initiate Payment task in Camunda Modeler.
- Select the circular icon with a double line border.
- Click on the wrench icon next to the newly-created event.
- Select the Message Intermediate Catch Event.
- Double-click on the message event and label it
We use message catch events in Zeebe when the workflow engine needs to receive a message from an external system before the process instance can advance. (See: Message Events)
In the scenario we're modeling, we initiate a payment with our service task, but we need to wait for some other external system to confirm the payment was received. This confirmation comes in the form of a message that is sent to Zeebe (asynchronously) by an external service.
Messages received by Zeebe must be correlated to specific process instances. To make this possible, we have some more configuring to do. Take the following steps:
- Select the message event and make sure you're on the General tab of the properties panel on the right side of the screen.
- In the Properties panel, click the + icon to create a new message. You'll now see two fields in Modeler that we'll use to correlate a message to a specific process instance: message name and subscription correlation key.
- Give this message a self-explanatory name:
When Zeebe receives a message, this name field lets us know which message event in the process model the message is referring to.
But how do we know which specific process instance—that is, which customer order—a message refers to? That's where subscription correlation key comes in. The subscription correlation key is a unique ID present in both the process instance payload and the message sent to Zeebe.
orderId for our correlation key. Take the following steps:
- Add the expression
= orderIdto the subscription correlation key field.
- When we create a process instance, we need to be sure to include
orderIdas a variable, and we also need to provide
orderIdas a correlation key when we send a message.
Here's what you should see in Modeler:
Next, we'll add an exclusive (XOR) gateway to our process model. The exclusive gateway is used to make a data-based decision about which path a process instance should follow. In this case, we want to ship items with insurance if total order value is greater than or equal to $100 and ship without insurance otherwise.
That means when we create a process instance, we'll need to include order value as an instance variable. We'll come to this later.
First, let's take the necessary steps to configure our process model to make this decision. To add the gateway, take the following steps:
- Click on the message event you just created.
- Select the gateway (diamond-shaped) symbol. The exclusive gateway is the default when you add a new gateway to a model.
- Double-click on the gateway and add a label
Order Value?so it's clear what we're using as our decision criteria.
We'll add two outgoing sequence flows from this exclusive gateway that lead to two different service tasks. Each sequence flow will have a data-based condition that's evaluated in the context of the process instance payload.
Take the following steps:
- Select the gateway and add a new service task to the model.
- Label the task
Ship Without Insurance.
- Set the Type to
Whenever we use an exclusive gateway, we want to be sure to set a default flow, which in this case will be shipping without insurance:
- Select the sequence flow you just created from the gateway to the
Ship Without Insuranceservice task.
- Click on the wrench icon.
- Choose Default Flow.
Now we're ready to add a second outgoing sequence flow and service task from the gateway. Take the following steps:
- Select the gateway again.
- Add another service task to the model.
- Label it
Ship With Insurance.
- Set the Type to
Next, we'll set a condition expression in the sequence flow leading to this
Ship With Insurance service task:
- Click on the sequence flow and open the Properties panel.
- Input the expression
= orderValue >= 100in the Condition expression field in the Properties panel.
- Double-click on the sequence flow to add a label "
We're almost finished! To wrap things up, we'll:
- Select the
Ship Without Insurancetask.
- Add another exclusive gateway to the model to merge the branches together again (a BPMN best practice in a model like this one).
- Select the
Ship With Insurancetask.
- Add an outgoing sequence flow that connects to the second exclusive gateway you just created.
The only BPMN element we need to add is an end event:
- Click on the second exclusive gateway.
- Add an end event.
- Double-click on it to label it
Lastly, we'll change the process Id to something more descriptive than the default
Process_1 that you'll see in Modeler. Take the following steps:
- Click onto a blank part of the canvas.
- Open the Properties panel.
- Change the Id to
Here's what you should see in Modeler after these last few updates:
That's all for our modeling step. Remember to save the file one more time to prepare to deploy the process to Zeebe, create process instances, and complete them.