Skip to content

Commit

Permalink
Adjusted example to a more common Spring Boot application (related to #…
Browse files Browse the repository at this point in the history
  • Loading branch information
berndruecker committed Oct 12, 2022
1 parent 51b4f64 commit 193e12d
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 145 deletions.
4 changes: 2 additions & 2 deletions examples/worker/pom.xml → example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</parent>

<groupId>io.camunda</groupId>
<artifactId>spring-zeebe-example-worker</artifactId>
<name>example/spring-zeebe-example-worker</name>
<artifactId>spring-zeebe-example</artifactId>
<name>example/spring-zeebe-example</name>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.camunda.zeebe.spring.example;

import io.camunda.zeebe.spring.client.EnableZeebeClient;
import io.camunda.zeebe.spring.client.annotation.Deployment;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableZeebeClient
@EnableScheduling
@Deployment(resources = "classpath:demoProcess.bpmn")
public class ExampleApplication {

public static void main(final String... args) {
SpringApplication.run(ExampleApplication.class, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import io.camunda.zeebe.client.api.worker.JobClient;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.spring.client.EnableZeebeClient;
import io.camunda.zeebe.spring.client.annotation.JobWorker;
import io.camunda.zeebe.spring.client.annotation.Variable;
import io.camunda.zeebe.spring.client.annotation.ZeebeVariable;
import io.camunda.zeebe.spring.client.annotation.ZeebeWorker;

import java.time.Instant;
import java.util.Collections;
import java.util.Map;
Expand All @@ -15,17 +13,28 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;

@SpringBootApplication
@EnableZeebeClient
public class WorkerApplication {
@Component
public class ExampleJobWorkers {

private static Logger log = LoggerFactory.getLogger(WorkerApplication.class);
private static Logger log = LoggerFactory.getLogger(ExampleJobWorkers.class);

public static void main(final String... args) {
SpringApplication.run(WorkerApplication.class, args);
@JobWorker(type = "foo") // autoComplete = true as default value
public void handleFooJob(final ActivatedJob job) {
logJob(job, null);
}

@JobWorker() // type is set to method name: "bar".
public Map<String, Object> bar(final ActivatedJob job, @Variable String a) {
logJob(job, a);
return Collections.singletonMap("someResult", "42");
}

@JobWorker(type = "fail", fetchAllVariables = true)
public void handleFailingJob(final JobClient client, final ActivatedJob job, @Variable String someResult) {
logJob(job, someResult);
throw new ZeebeBpmnError("DOESNT_WORK", "This will actually never work :-)");
}

private static void logJob(final ActivatedJob job, Object parameterValue) {
Expand All @@ -41,20 +50,4 @@ private static void logJob(final ActivatedJob job, Object parameterValue) {
job.getVariables());
}

@JobWorker(type = "foo")
public void handleFooJob(final ActivatedJob job) {
logJob(job, null);
}

@JobWorker()
public Map<String, Object> bar(final ActivatedJob job, @Variable String a) {
logJob(job, a);
return Collections.singletonMap("someResult", "42");
}

@JobWorker(type = "fail", autoComplete = true, fetchAllVariables = true)
public void handleFailingJob(final JobClient client, final ActivatedJob job, @Variable String someResult) {
logJob(job, someResult);
throw new ZeebeBpmnError("DOESNT_WORK", "This will actually never work :-)");
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
package io.camunda.zeebe.spring.example;

import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import io.camunda.zeebe.spring.client.EnableZeebeClient;
import io.camunda.zeebe.spring.client.annotation.Deployment;
import io.camunda.zeebe.spring.client.lifecycle.ZeebeClientLifecycle;
import io.camunda.zeebe.spring.client.annotation.ZeebeDeployment;

import java.util.Date;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@SpringBootApplication
@EnableZeebeClient
@EnableScheduling
@Deployment(resources = "classpath:demoProcess.bpmn")
public class StarterApplication {
import java.util.Date;
import java.util.UUID;

private static Logger log = LoggerFactory.getLogger(StarterApplication.class);
@Component
public class PeriodicProcessStarter {

public static void main(final String... args) {
SpringApplication.run(StarterApplication.class, args);
}
private static Logger log = LoggerFactory.getLogger(ExampleApplication.class);

@Autowired
private ZeebeClientLifecycle client;
Expand Down
File renamed without changes.
49 changes: 0 additions & 49 deletions examples/pom.xml

This file was deleted.

40 changes: 0 additions & 40 deletions examples/starter/pom.xml

This file was deleted.

2 changes: 0 additions & 2 deletions examples/worker/src/main/resources/application.properties

This file was deleted.

5 changes: 0 additions & 5 deletions examples/worker/src/main/resources/logback-spring.xml

This file was deleted.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<module>client</module>

<module>examples</module>
<module>example</module>
</modules>

<dependencyManagement>
Expand Down

0 comments on commit 193e12d

Please sign in to comment.