This project allows to leverage Zeebe within your Spring or Spring Boot environment easily. It is basically a wrapper around the Zeebe Java Client.
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;
Use the @ZeebeDeployment
annotation:
@SpringBootApplication
@EnableZeebeClient
@ZeebeDeployment(classPathResources = "demoProcess.bpmn")
public class MySpringBootApplication {
You can also deploy multiple files at once:
@ZeebeDeployment(classPathResources ={"demoProcess.bpmn", "demoProcess2.bpmn"})
@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); });
}
Connections to the Camunda Cloud can be easily configured:
zeebe.client.cloud.clusterId=xxx
zeebe.client.cloud.clientId=xxx
zeebe.client.cloud.clientSecret=xxx
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.
zeebe.client.broker.gatewayAddress=127.0.0.1:26500
zeebe.client.security.plaintext=true
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
For a full set of configuration options please see ZeebeClientConfigurationProperties.java
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);
}
}
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>
Have a look into the examples/ folder for working Maven projects that might serve as inspiration.
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.