/process-engine-worker

Primary LanguageKotlinApache License 2.0Apache-2.0

Process Engine API Worker

incubating Development branches Maven Central

Purpose of the library

A small opinionated annotated-based SpringBoot worker implementation for creation of external task workers using Process-Engine-API.

How to use

Add the following dependency to your project's class path:

<dependency>
  <groupId>dev.bpm-crafters.process-engine-worker</groupId>
  <artifactId>process-engine-worker-spring-boot-starter</artifactId>
</dependency>

Provide a Spring Component and annotate its method as following:

@Component
public class MyWorker {
  
  @ProcessEngineWorker(topic = "fetchGoods")
  public void fetchGoods(
    TaskInformation taskInformation,
    ExternalTaskCompletionApi externalTaskCompletionApi,
    @Variable(name = "order") Order order
  ) {
    // execute some business code

    // complete the task using process engine API
    externalTaskCompletionApi.completeTask(
      new CompleteTaskCmd(taskInformation.getTaskId(), () -> Map.of("shipped", true))
    ).get();
  }
}

Examples

There is an Order fulfillment example, you can easily try out. It follows the approach of clean architecture and uses Process Engine API and Process Engine Worker libraries. To run it, you have two options:

Running locally

  1. Start docker-compose.yaml (this will start containerized Zeebe locally)
  2. Start FulfillmentProcessApplication activating Spring profile local.

Running using Camunda SaaS

  • Start FulfillmentProcessApplication activating Spring profile cloud and pass the following environment variables:
ZEEBE_REGION=..
ZEEBE_CLUSTER_ID=..
ZEEBE_CLIENT_ID=..
ZEEBE_CLIENT_SECRET=...