Skip to content
Permalink
Browse files

Switched Zeebe version of flowing-retail (Zeebe = Work Distribution) …

…to Zeebe 0.17
  • Loading branch information...
berndruecker committed Apr 30, 2019
1 parent 60b44c8 commit 9686ed6436fd6fbb92a8f69b84e59b20a2cb0f5e
@@ -1,5 +1,5 @@
@echo off
TITLE Zeebe
TITLE ElasticsearchForZeebe

set mypath=%cd%
FOR /F "tokens=1,2 delims==" %%G IN (environment.properties) DO (set %%G=%%H)
@@ -8,7 +8,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
<zeebe.version>0.12.0-alpha4</zeebe.version>
<zeebe.version>0.17.0</zeebe.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -28,7 +28,7 @@
</dependency>
<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-gateway</artifactId>
<artifactId>zeebe-client-java</artifactId>
<version>${zeebe.version}</version>
</dependency>
<dependency>
@@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.client.ZeebeClient;

@SpringBootApplication
public class CheckoutApplication {
@@ -13,7 +13,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.client.ZeebeClient;

@RestController
public class ShopRestController {
@@ -50,10 +50,10 @@ public String placeOrder(@RequestParam(value = "customerId") String customerId)
// a message to broker - which will correlate it himself
// this is not yet in the current version of zeebe - so we
// have to specify the workflow to start
zeebe.workflowClient().newCreateInstanceCommand() //
zeebe.newCreateInstanceCommand() //
.bpmnProcessId("order-zeebe") //
.latestVersion() //
.payload(payload) //
.variables(payload) //
.send().join();
} catch (Exception e) {
throw new RuntimeException("Could not tranform and send message due to: "+ e.getMessage(), e);
@@ -8,7 +8,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
<zeebe.version>0.12.0-alpha4</zeebe.version>
<zeebe.version>0.17.0</zeebe.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -28,7 +28,7 @@
</dependency>
<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-gateway</artifactId>
<artifactId>zeebe-client-java</artifactId>
<version>${zeebe.version}</version>
</dependency>
</dependencies>
@@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.client.ZeebeClient;

@SpringBootApplication
public class InventoryApplication {
@@ -8,11 +8,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.gateway.api.clients.JobClient;
import io.zeebe.gateway.api.events.JobEvent;
import io.zeebe.gateway.api.subscription.JobHandler;
import io.zeebe.gateway.api.subscription.JobWorker;
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.clients.JobClient;
import io.zeebe.client.api.response.ActivatedJob;
import io.zeebe.client.api.subscription.JobHandler;
import io.zeebe.client.api.subscription.JobWorker;


@Component
@@ -25,7 +25,7 @@

@PostConstruct
public void subscribe() {
subscription = zeebe.jobClient().newWorker()
subscription = zeebe.newWorker()
.jobType("fetch-goods-z")
.handler(this)
.timeout(Duration.ofMinutes(1))
@@ -38,9 +38,9 @@ public void closeSubscription() {
}

@Override
public void handle(JobClient client, JobEvent job) {
public void handle(JobClient client, ActivatedJob job) {
System.out.println("fetch goods");
client.newCompleteCommand(job).send().join();
client.newCompleteCommand(job.getKey()).send().join();
}

}
@@ -8,7 +8,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
<zeebe.version>0.12.0-alpha4</zeebe.version>
<zeebe.version>0.17.0</zeebe.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -28,7 +28,7 @@
</dependency>
<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-gateway</artifactId>
<artifactId>zeebe-client-java</artifactId>
<version>${zeebe.version}</version>
</dependency>
<dependency>
@@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.client.ZeebeClient;

@SpringBootApplication
public class OrderApplication {
@@ -15,7 +15,7 @@ public ZeebeClient zeebe() {
ZeebeClient zeebeClient = ZeebeClient.newClient();

// Trigger deployment
zeebeClient.workflowClient().newDeployCommand() //
zeebeClient.newDeployCommand() //
.addResourceFromClasspath("order-zeebe.bpmn") //
.send().join();

@@ -10,11 +10,12 @@

import io.flowing.retail.zeebe.order.domain.Order;
import io.flowing.retail.zeebe.order.persistence.OrderRepository;
import io.zeebe.gateway.ZeebeClient;
import io.zeebe.gateway.api.clients.JobClient;
import io.zeebe.gateway.api.events.JobEvent;
import io.zeebe.gateway.api.subscription.JobHandler;
import io.zeebe.gateway.api.subscription.JobWorker;
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.clients.JobClient;
import io.zeebe.client.api.events.JobEvent;
import io.zeebe.client.api.response.ActivatedJob;
import io.zeebe.client.api.subscription.JobHandler;
import io.zeebe.client.api.subscription.JobWorker;


@Component
@@ -30,7 +31,7 @@

@PostConstruct
public void subscribe() {
subscription = zeebe.jobClient().newWorker()
subscription = zeebe.newWorker()
.jobType("save-order-z")
.handler(this)
.timeout(Duration.ofMinutes(1))
@@ -43,9 +44,8 @@ public void closeSubscription() {
}

@Override
public void handle(JobClient client, JobEvent job) {
// read data
OrderFlowContext context = OrderFlowContext.fromJson(job.getPayload());
public void handle(JobClient client, ActivatedJob job) {
OrderFlowContext context = OrderFlowContext.fromJson(job.getVariables());
Order order = context.getOrder();

// do something with it
@@ -56,9 +56,8 @@ public void handle(JobClient client, JobEvent job) {

// done
System.out.println("persisted order " + order.getId());
client.newCompleteCommand(job) //
.payload(context.asJson()) //
client.newCompleteCommand(job.getKey()) //
.variables(context.asJson()) //
.send().join();
}

}
@@ -8,9 +8,9 @@
<bpmn:extensionElements>
<zeebe:taskDefinition type="retrieve-payment-z" />
<zeebe:ioMapping>
<zeebe:input source="$.order.totalSum" target="$.amount" />
<zeebe:input source="$.order.orderId" target="$.refId" />
<zeebe:input source="$.traceId" target="$.traceId" />
<zeebe:input source="order.totalSum" target="amount" />
<zeebe:input source="order.orderId" target="refId" />
<zeebe:input source="traceId" target="traceId" />
</zeebe:ioMapping>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1e3ow6n</bpmn:incoming>
@@ -8,7 +8,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
<zeebe.version>0.12.0-alpha4</zeebe.version>
<zeebe.version>0.17.0</zeebe.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -28,7 +28,7 @@
</dependency>
<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-gateway</artifactId>
<artifactId>zeebe-client-java</artifactId>
<version>${zeebe.version}</version>
</dependency>
</dependencies>
@@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.client.ZeebeClient;

@SpringBootApplication
public class PaymentApplication {
@@ -8,13 +8,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.ObjectMapper;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.gateway.api.clients.JobClient;
import io.zeebe.gateway.api.events.JobEvent;
import io.zeebe.gateway.api.subscription.JobHandler;
import io.zeebe.gateway.api.subscription.JobWorker;
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.clients.JobClient;
import io.zeebe.client.api.response.ActivatedJob;
import io.zeebe.client.api.subscription.JobHandler;
import io.zeebe.client.api.subscription.JobWorker;


@Component
@@ -27,28 +25,26 @@

@PostConstruct
public void subscribe() {
subscription = zeebe.jobClient().newWorker()
subscription = zeebe.newWorker()
.jobType("retrieve-payment-z")
.handler(this)
.timeout(Duration.ofMinutes(1))
.open();
}

@Override
public void handle(JobClient client, JobEvent job) {
public void handle(JobClient client, ActivatedJob job) {
try {
PaymentInput data = new ObjectMapper().readValue(job.getPayload(), PaymentInput.class);
String traceId = data.getTraceId();

String refId = data.getRefId();
long amount = data.getAmount();
String traceId = (String) job.getVariablesAsMap().get("traceId");
String refId = (String) job.getVariablesAsMap().get("refId");
long amount = (Integer) job.getVariablesAsMap().get("amount");

System.out.println("retrieved payment " + amount + " for " + refId);
} catch (Exception e) {
throw new RuntimeException("Could not parse payload: " + e.getMessage(), e);
}

client.newCompleteCommand(job).send().join();
client.newCompleteCommand(job.getKey()).send().join();
}

@PreDestroy

This file was deleted.

Oops, something went wrong.
@@ -8,7 +8,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
<zeebe.version>0.12.0-alpha4</zeebe.version>
<zeebe.version>0.17.0</zeebe.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -28,7 +28,7 @@
</dependency>
<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-gateway</artifactId>
<artifactId>zeebe-client-java</artifactId>
<version>${zeebe.version}</version>
</dependency>
</dependencies>
@@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.client.ZeebeClient;

@SpringBootApplication
public class ShippingApplication {
@@ -8,11 +8,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import io.zeebe.gateway.ZeebeClient;
import io.zeebe.gateway.api.clients.JobClient;
import io.zeebe.gateway.api.events.JobEvent;
import io.zeebe.gateway.api.subscription.JobHandler;
import io.zeebe.gateway.api.subscription.JobWorker;
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.clients.JobClient;
import io.zeebe.client.api.response.ActivatedJob;
import io.zeebe.client.api.subscription.JobHandler;
import io.zeebe.client.api.subscription.JobWorker;


@Component
@@ -25,17 +25,17 @@

@PostConstruct
public void subscribe() {
subscription = zeebe.jobClient().newWorker()
subscription = zeebe.newWorker()
.jobType("ship-goods-z")
.handler(this)
.timeout(Duration.ofMinutes(1))
.open();
}

@Override
public void handle(JobClient client, JobEvent job) {
public void handle(JobClient client, ActivatedJob job) {
System.out.println("ship goods");
client.newCompleteCommand(job).send().join();
client.newCompleteCommand(job.getKey()).send().join();
}

@PreDestroy

0 comments on commit 9686ed6

Please sign in to comment.
You can’t perform that action at this time.