Quick serverless start to Camunda Cloud Public Beta
Untangle the microservice mess by using serverless orchestration
Have you heard about Camunda and Zeebe? Camunda is a company that does fantastic open-source BPMN engine and ecosystem around it, and also, they created the BPMN engine specifically designed to run cloud and serverless workloads — Zeebe.
2 days ago, they released a Public Beta of Zeebe SaaS called Camunda Cloud.
By using Camunda Cloud, you can create serverless workflows and orchestrate your microservice architecture without running an instance of Camunda BPMN or Zeebe in Docker or Kubernetes.
Here are the examples of the tasks suitable for serverless orchestration:
Order fulfillment
Underwriting
KYC
Follow-up email (1d, 5d, etc…)
Scheduled Batch processing
Custom CI/CD
Backups
User sign-up flow
Let’s have a quick example of creating a new workflow and executing it in Camunda Cloud.
First steps
To create a serverless orchestration workflow, you need:
Register for Camunda Cloud: https://bit.ly/3aJjjHz Follow the link, and you will receive an invitation to your e-mail
Download Zeebe Modeler. It is needed for creating a BPMN workflow compatible with Camunda Cloud.
Download zbctl by installing it via npm “npm i -g zbctl” or by downloading from releases page: https://github.com/zeebe-io/zeebe/releases
Recommended reading
Getting started guide
https://zeebe.io/blog/2019/09/getting-started-camunda-cloud/
Zeebe Http Worker
https://github.com/zeebe-io/zeebe-http-worker
Creating first workflow
You can create a workflow in Zeebe Modeler, or you can download example workflow for my Serverless workflow orchestration talk from GitHub, see here: https://github.com/huksley/aws-detect-faces-workflow/blob/master/detect-faces-zeebe.bpmn
As we don’t have serverless functions running, we will use https://webhook.site/ to see any incoming requests from Camunda Cloud workflow running.
How workflow invokes serverless functions?
Currently, there is the only way to invoke them by using an HTTP worker, called CAMUNDA-HTTP. For this to work, you define headers and variables in the Service task, so HTTP worker knows what to invoke.
Define following headers:
url: ${baseUrl}?do=mytask1
method: post
Define following input variables:
source: name
target: body.name
By specifying this variables, ${baseUrl}?do=mytask1 will be called with POST and body will contain { name: “Value”} JSON.
Create cluster instance in Camunda Cloud
Go to Camunda Cloud and create the first and only cluster we will use in this example.
To receive requests, visit webhook.site and create a unique URL which will be a base address for every request we receive from Camunda Cloud workflow:
Do not close this page! As your workflow executes, you will receive requests there and can inspect payloads.
Define your webhook.site URL in the HTTP worker variables:
Deploying workflow
By using zbctl, we can deploy workflow from the command line after creating it in Zeebe Modeler.
To do that, you need to copy and save cluster configuration and credentials as seen in Camunda Cloud — Zeebe Contact Point, clientId and clientSecret.
> zbctl --address $CONTACTPOINT_ADDRESS:443 status \ --clientId $CLIENTID --clientSecret $CLIENTSECRET \ deploy detect-faces-zeebe.bpmn Error: rpc error: code = InvalidArgument desc = Command rejected with code 'CREATE': Expected to deploy new resources, but encountered the following errors: 'detect-faces-zeebe.bpmn': - Element: ErrorEventDefinition_0hgorsz - ERROR: ErrorCode must be present and not empty - Element: ErrorEventDefinition_1ropsen - ERROR: ErrorCode must be present and not empty - Element: ErrorEventDefinition_13mgmyc - ERROR: Must reference an error - Element: IntermediateThrowEvent_14k3r67 - ERROR: Must have exactly one event definition > zbctl --address $CONTACTPOINT_ADDRESS:443 status \ --clientId $CLIENTID --clientSecret $CLIENTSECRET \ deploy detect-faces-zeebe.bpmn { "key": 2251799813688077, "workflows": [ { "bpmnProcessId": "Process_1j8gwvl", "version": 1, "workflowKey": 2251799813688076, "resourceName": "detect-faces-zeebe.bpmn" } ] }
If you encounter errors, fix them and redeploy them again. My example BPMN workflow should be compatible with version 0.22 of Zeebe running in the Camunda Cloud now.
After you created the workflow, you will get process id in bpmnProcessId variable:
{ “workflowKey”: 2251799813688076, “bpmnProcessId”: “Process_1j8gwvl”, “version”: 1, “workflowInstanceKey”: 2251799813688081 }
Starting first instance
Now you can create execution that will call your services, and you will see invocation in webhook.site.
Using bpmnProcessId value after deploy workflow, create an instance by using zbctl:
zbctl --address $CONTACTPOINT_ADDRESS:443 status \ --clientId $CLIENTID --clientSecret $CLIENTSECRET \ create instance Process_1j8gwvl --variables '{ "name": "John" }' { "workflowKey": 2251799813688076, "bpmnProcessId": "Process_1j8gwvl", "version": 1, "workflowInstanceKey": 2251799813688081 }
Now you got information about your new execution in JSON:
{ “workflowKey”: 2251799813688076, “bpmnProcessId”: “Process_1j8gwvl”, “version”: 1, “workflowInstanceKey”: 2251799813688081 }
Tracking your executions in Camunda Operate
To see how your execution progresses, follow the link Camunda Cloud console View Workflow Instances in Camunda Operate:
It will show you all running, completed or failed executions for a version of workflow.
Receive workflow execution in Webhook.site
Going deeper
Great next actions are to read the documentation at https://docs.zeebe.io/, create new workflows in Zeebe Modeler, and run serverless functions to power your workflows.
About author
Ruslan Gainutdinov is an architect, DevRel, serverless, and workflow orchestration advocate and has more than 20 years of Software engineering experience.
If you have any questions, reach Ruslan on Twitter or LinkedIn.