camunda-community-hub / zeebe-http-worker

Zeebe worker for HTTP calls
Apache License 2.0
45 stars 28 forks source link
extension http zeebe zeebe-worker

zeebe-http-worker

License

Compatible with: Camunda Platform 8

[!IMPORTANT] This community extension is deprecated. You should prefer the official Camunda REST connector. The connector is available in Camunda SaaS and for self-managed. Further resources:

Thank you to all contributors for making it a great extension. :tada:

A Zeebe worker to make HTTP calls (e.g. invoking a REST service). It is based on the built-in Java HttpClient.

Usage

BPMN Task

Example BPMN with service task:

<bpmn:serviceTask id="http-get" name="stargazers check">
  <bpmn:extensionElements>
    <zeebe:taskDefinition type="http" />
    <zeebe:taskHeaders>
      <zeebe:header key="url" value="https://api.github.com/user/starred/zeebe-io/zeebe-http-worker" />
    </zeebe:taskHeaders>
  </bpmn:extensionElements>
</bpmn:serviceTask>

Placeholders

Please note that the current way of handling placeholders is subject to change in the future, especially with https://github.com/zeebe-io/zeebe/issues/3417.

You can use placeholders in the form of {{PLACEHOLDER}} at all places, they will be replaced by

Mustache is used for replacing the placeholders, refer to their docs to check possibilities.

Example:

<bpmn:serviceTask id="http-get" name="stargazers check">
  <bpmn:extensionElements>
    <zeebe:taskDefinition type="http" />
    <zeebe:taskHeaders>
      <zeebe:header key="url" value="https://{{BASE_URL}}/order?id={{orderId}}" />
      <zeebe:header key="method" value="GET" />
    </zeebe:taskHeaders>
  </bpmn:extensionElements>
</bpmn:serviceTask>

BASE_URL could be configured by the configuration variables from the URL and the orderId might be a workflow variable.

To support some legacy scenarios the worker at the moment still also understands placeholders in the form of ${PLACEHOLDER}. This is subject to be removed in later releases.

HTTP Response codes

As described you can set the statusCodeCompletion and statusCodeFailure header to control the behavior depending on the HTTP Status. If the status code is in neither of the lists Zeebe will just keep waiting in the service task, allowing for asynchronous callbacks.

A common example is

To allow this, the jobKey can be passed to the external service.

Install

Docker

The docker image for the worker is published to GitHub Packages.

docker pull ghcr.io/camunda-community-hub/zeebe-http-worker:1.0.0

For a local setup, the repository contains a docker-compose file. It starts a Zeebe broker and the worker.

cd docker
docker-compose up

Manual

  1. Download the latest worker JAR (zeebe-http-worker-%{VERSION}.jar )

  2. Start the worker java -jar zeebe-http-worker-{VERSION}.jar

Readiness probes

You can check health of the worker:

http://localhost:8080/actuator/health

This uses the Spring Actuator, so other metrics are available as well

Configuration of Zeebe Connection

The connection to the broker Zeebe can be changed by setting the environment variables

This worker uses Spring Zeebe underneath, so all configuration options available there are also available here.

Configuration Variables

You can load additional configuration values used to substitute placeholders:

Remote Variables Configuration

If ENV_VARS_URL is configured, the worker will query an HTTP endpoint and expects a JSON back:

[
  {
    "key": "someValue",
    "value": 42
  },
  {
    "key": "anotherValue",
    "value": 42
  }
]

To load additional config variables from an URL set these environment variables:

Local Environment Variables

To avoid exposing sensitive information, a prefix can be used to filter environment variables.

To change the prefix set these environment variables:

Build from Source

Build with Maven

mvn clean install

Code of Conduct

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to code-of-conduct@zeebe.io.