Skip to content

Commit

Permalink
improved after feedback from ingo
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlukas committed Dec 13, 2024
1 parent d475011 commit 209fce8
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 12 deletions.
8 changes: 7 additions & 1 deletion event-processing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ A message event that should be able to work with the event processor should:

* define a message name that matches the events' name
* if not a start event, define a correlation key that matches the events' id
* have an end listener with the job type `correlated`
* have an end listener or a following service task with the job type `correlated`

Now, an event can be published and its state can be tracked with the rest api:

Expand Down Expand Up @@ -100,3 +100,9 @@ mvn spring-boot:run
```

To connect against another cluster (saas for example), you can adjust the application.yaml according to [this guide](https://docs.camunda.io/docs/apis-tools/spring-zeebe-sdk/getting-started/).

There is an example [process](./src/test/resources/eventHandler.bpmn) and [request](./src/test/resources/createEventRequest.json) available in the tests.

Just deploy the process and send a request to publish an event as documented above.

![img.png](docs/img4.png)
Binary file added event-processing/docs/img4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.camunda.consulting.eventprocessing;

import io.camunda.zeebe.spring.client.annotation.JobWorker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class ExampleServiceCalls {
private static final Logger LOG = LoggerFactory.getLogger(ExampleServiceCalls.class);

@JobWorker
public void service1() {
LOG.info("Service 1 called");
}

@JobWorker
public void service2() {
LOG.info("Service 2 called");
}

@JobWorker
public void service3() {
LOG.info("Service 3 called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@
import java.util.Objects;
import java.util.function.Function;

/**
* Please ignore this class for the example.
*
* <p>This is just a generic mapper to map dto - pojo - entity as they are separated
*/
public class Mapper {
private static final Map<Class<?>, Map<Class<?>, Function<?, ?>>> MAPPER_REGISTRY =
new HashMap<>();
private static ObjectMapper objectMapper = new ObjectMapper();
private static final ObjectMapper objectMapper = new ObjectMapper();

static {
Arrays.stream(Mapper.class.getDeclaredMethods())
Expand Down
79 changes: 69 additions & 10 deletions event-processing/src/test/resources/eventHandler.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_083ntxc" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.29.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_083ntxc" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.30.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0">
<bpmn:process id="eventHandler" name="Event Handler" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" name="Event received">
<bpmn:extensionElements>
Expand All @@ -11,29 +11,88 @@
<bpmn:messageEventDefinition id="MessageEventDefinition_12dmrmh" messageRef="Message_1m3ttt6" />
</bpmn:startEvent>
<bpmn:endEvent id="Event_06kbjy6" name="Event handled">
<bpmn:incoming>Flow_07icx7o</bpmn:incoming>
<bpmn:incoming>Flow_0zg3kkg</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_07icx7o" sourceRef="StartEvent_1" targetRef="Event_06kbjy6" />
<bpmn:sequenceFlow id="Flow_07icx7o" sourceRef="StartEvent_1" targetRef="Activity_1pn0yy4" />
<bpmn:sequenceFlow id="Flow_0xz040e" sourceRef="Activity_1pn0yy4" targetRef="Activity_1aymgmx" />
<bpmn:serviceTask id="Activity_1pn0yy4" name="Call service 1">
<bpmn:extensionElements>
<zeebe:taskDefinition type="service1" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_07icx7o</bpmn:incoming>
<bpmn:outgoing>Flow_0xz040e</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="Activity_1aymgmx" name="Call service 2">
<bpmn:extensionElements>
<zeebe:taskDefinition type="service2" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_0xz040e</bpmn:incoming>
<bpmn:outgoing>Flow_01qhw0g</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_01qhw0g" sourceRef="Activity_1aymgmx" targetRef="Activity_1qlry9c" />
<bpmn:serviceTask id="Activity_1qlry9c" name="Call service 3">
<bpmn:extensionElements>
<zeebe:taskDefinition type="service3" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_01qhw0g</bpmn:incoming>
<bpmn:outgoing>Flow_0zg3kkg</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0zg3kkg" sourceRef="Activity_1qlry9c" targetRef="Event_06kbjy6" />
<bpmn:textAnnotation id="TextAnnotation_1ww64ze">
<bpmn:text>The published ack happens as end listener, can also be a separate service task</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_1hjlr3o" associationDirection="None" sourceRef="StartEvent_1" targetRef="TextAnnotation_1ww64ze" />
</bpmn:process>
<bpmn:message id="Message_1m3ttt6" name="random" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="eventHandler">
<bpmndi:BPMNShape id="Event_00mzolj_di" bpmnElement="StartEvent_1">
<dc:Bounds x="182" y="82" width="36" height="36" />
<dc:Bounds x="182" y="232" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="164" y="125" width="73" height="14" />
<dc:Bounds x="164" y="275" width="73" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1bdtnp7_di" bpmnElement="Activity_1pn0yy4">
<dc:Bounds x="300" y="210" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_0vxiwg1" bpmnElement="Activity_1aymgmx">
<dc:Bounds x="460" y="210" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_0ueid43" bpmnElement="Activity_1qlry9c">
<dc:Bounds x="620" y="210" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_06kbjy6_di" bpmnElement="Event_06kbjy6">
<dc:Bounds x="272" y="82" width="36" height="36" />
<dc:Bounds x="782" y="232" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="255" y="125" width="71" height="14" />
<dc:Bounds x="765" y="275" width="71" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_1hjlr3o_di" bpmnElement="Association_1hjlr3o">
<di:waypoint x="210" y="235" />
<di:waypoint x="250" y="173" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="TextAnnotation_1ww64ze_di" bpmnElement="TextAnnotation_1ww64ze">
<dc:Bounds x="250" y="80" width="100" height="98" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_07icx7o_di" bpmnElement="Flow_07icx7o">
<di:waypoint x="218" y="100" />
<di:waypoint x="272" y="100" />
<di:waypoint x="218" y="250" />
<di:waypoint x="300" y="250" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0xz040e_di" bpmnElement="Flow_0xz040e">
<di:waypoint x="400" y="250" />
<di:waypoint x="460" y="250" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_01qhw0g_di" bpmnElement="Flow_01qhw0g">
<di:waypoint x="560" y="250" />
<di:waypoint x="620" y="250" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0zg3kkg_di" bpmnElement="Flow_0zg3kkg">
<di:waypoint x="720" y="250" />
<di:waypoint x="782" y="250" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
</bpmn:definitions>

0 comments on commit 209fce8

Please sign in to comment.