A small opinionated annotated-based SpringBoot worker implementation for creation of external task workers using Process-Engine-API.
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();
}
}
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:
- Start
docker-compose.yaml
(this will start containerized Zeebe locally) - Start
FulfillmentProcessApplication
activating Spring profilelocal
.
- Start
FulfillmentProcessApplication
activating Spring profilecloud
and pass the following environment variables:
ZEEBE_REGION=..
ZEEBE_CLUSTER_ID=..
ZEEBE_CLIENT_ID=..
ZEEBE_CLIENT_SECRET=...