Giter VIP home page Giter VIP logo

spring-zeebe's Introduction

Spring Zeebe

Maven Central

Build Status codecov Project Stats

This project allows to leverage Zeebe within your Spring or Spring Boot environment easily. It is basically a wrapper around the Zeebe Java Client.

Add Spring Boot Starter to Your Project

Just add the following Maven dependency to your Spring Boot Starter project:

<dependency>
	<groupId>io.camunda</groupId>
	<artifactId>spring-zeebe-starter</artifactId>
	<version>${CURRENT_VERSION}</version>
</dependency>

How to use

Connect to Zeebe Broker

Just add the @EnableZeebeClient annotation to your Spring Boot Application:

@SpringBootApplication
@EnableZeebeClient
public class MySpringBootApplication {

Now you can inject the ZeebeClient and work with it, e.g. to create new workflow instances:

@Autowired
private ZeebeClient client;

Deploy Process Models

Use the @ZeebeDeployment annotation:

@SpringBootApplication
@EnableZeebeClient
@ZeebeDeployment(resources = "classpath:demoProcess.bpmn")
public class MySpringBootApplication {

This annotation uses (which internally uses [https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#resources-resourceloader](the Spring resource loader) mechanism which is pretty powerful and can for example also deploy multiple files at once:

@ZeebeDeployment(resources = {"classpath:demoProcess.bpmn" , "classpath:demoProcess2.bpmn"})

or define wildcard patterns:

@ZeebeDeployment(resources = "classpath*:/bpmn/**/*.bpmn")

Implement Job Worker

@ZeebeWorker(type = "foo")
public void handleJobFoo(final JobClient client, final ActivatedJob job) {
  // do whatever you need to do
  client.newCompleteCommand(job.getKey()) 
     .variables("{\"fooResult\": 1}")
     .send()
     .exceptionally( throwable -> { throw new RuntimeException("Could not complete job " + job, throwable); });
}

Configuring Camunda Cloud Connection

Connections to the Camunda Cloud can be easily configured:

zeebe.client.cloud.clusterId=xxx
zeebe.client.cloud.clientId=xxx
zeebe.client.cloud.clientSecret=xxx
zeebe.client.cloud.region=bru-2

If you don't connect to the Camunda Cloud production environment you might have to also adjust these two properties:

zeebe.client.cloud.baseUrl=zeebe.camunda.io
zeebe.client.cloud.port=443
zeebe.client.cloud.authUrl=https://login.cloud.camunda.io/oauth/token

As an alternative you can use the Zeebe Client environment variables.

Configuring Self-managed Zeebe Connection

zeebe.client.broker.gatewayAddress=127.0.0.1:26500
zeebe.client.security.plaintext=true

Additional Configuration Options

If you build a worker that only serves one thing, it might also be handy to define the worker job type globally - and not in the annotation:

zeebe.client.worker.defaultType=foo

Number of jobs that are polled from the broker to be worked on in this client and thread pool size to handle the jobs:

zeebe.client.worker.maxJobsActive=32
zeebe.client.worker.threads=1

For a full set of configuration options please see ZeebeClientConfigurationProperties.java

ObjectMapper customization

If you need to customize the ObjectMapper that the Zeebe client uses to work with variables, you can declare a bean with type io.camunda.zeebe.client.api.JsonMapper like this:

@Configuration
class MyConfiguration {
  @Bean
  public JsonMapper jsonMapper() {
    new ZeebeObjectMapper().enable(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT);
  }
}

Examples

Have a look into the examples/ folder for working Maven projects that might serve as inspiration.

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 [email protected].

spring-zeebe's People

Contributors

jangalinski avatar berndruecker avatar menski avatar spulci avatar huangxiaoyu3331 avatar salaboy avatar ajeans avatar artunsubasi avatar thrum avatar chaima-mnsr avatar npepinpe avatar aivinog1 avatar gabac avatar meyerdan avatar imgbotapp avatar jwulf avatar pabloromanelli avatar saig0 avatar hawky-4s- avatar lzgabel avatar wenminglei avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.