Skip to content

Generator for Element Templates for Camunda Modeler from Job Workers using Spring Zeebe annotations

License

Notifications You must be signed in to change notification settings

camunda-community-hub/spring-zeebe-connector-template-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Community badge: Incubating Community extension badge

Spring Zeebe Connector Template Generator

Generator for Element Templates for Camunda Modeler from Job Workers using Spring Zeebe annotations.

Usage

Build using mvn clean install. Add the following dependency to your Spring Zeebe Maven project:

    <dependency>
      <groupId>org.camunda.community.extension.spring.zeebe.connector.template.generator</groupId>
      <artifactId>spring-zeebe-connector-template-generator</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </dependency>

Add the generator to the component scan of your ProcessApplication class:

@SpringBootApplication(
    scanBasePackageClasses = {
      ProcessApplication.class,
      SpringZeebeConnectorTemplateGenerator.class
    })

Example

Job Worker

package org.example.camunda.process.solution.worker;

import io.camunda.zeebe.spring.client.annotation.JobWorker;
import io.camunda.zeebe.spring.client.annotation.Variable;
import org.example.camunda.process.solution.ProcessVariables;
import org.example.camunda.process.solution.service.MyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class MyWorker {

  private static final Logger LOG = LoggerFactory.getLogger(MyWorker.class);

  private final MyService myService;

  public MyWorker(MyService myService) {
    this.myService = myService;
  }

  @JobWorker
  public ProcessVariables invokeMyService(@Variable String businessKey) {
    LOG.info("Invoking myService with variables: " + businessKey);

    boolean result = myService.myOperation(businessKey);

    return new ProcessVariables()
        .setResult(result); // new object to avoid sending unchanged variables
  }
}

Resulting template

{
  "$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
  "id": "invokeMyService",
  "name": "invokeMyService",
  "appliesTo": [
    "bpmn:Task"
  ],
  "elementType": {
    "value": "bpmn:ServiceTask"
  },
  "properties": [
    {
      "type": "Hidden",
      "value": "invokeMyService",
      "binding": {
        "type": "zeebe:taskDefinition:type"
      }
    }
,
    {
      "label": "businessKey",
      "description": "businessKey",
      "value": "=businessKey",
      "type": "String",
      "feel": "optional",
      "binding": {
        "type": "zeebe:input",
        "name": "businessKey"
      },
      "constraints": {
        "notEmpty": true
      }
    }
  ]
}

TODOs

About

Generator for Element Templates for Camunda Modeler from Job Workers using Spring Zeebe annotations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages