Changeset 25:12a32467beb6

Updated extension
author unexist
date Wed, 18 Aug 2021 08:19:00 +0200
parents 663d97e943f9
children 039c326f0bf0
files event-split-extension-parent/deployment/pom.xml event-split-extension-parent/deployment/src/main/java/dev/unexist/showcase/eventsplit/EventSplitProcessor.java event-split-extension-parent/runtime/pom.xml event-split-extension-parent/runtime/src/main/java/dev/unexist/showcase/eventsplit/EventSplitDispatcher.java
diffstat 4 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/event-split-extension-parent/deployment/pom.xml	Tue Aug 17 11:31:42 2021 +0200
+++ b/event-split-extension-parent/deployment/pom.xml	Wed Aug 18 08:19:00 2021 +0200
@@ -24,6 +24,10 @@
         </dependency>
         <dependency>
             <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-smallrye-reactive-messaging-deployment</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
             <artifactId>quarkus-smallrye-reactive-messaging-kafka-deployment</artifactId>
         </dependency>
 
--- a/event-split-extension-parent/deployment/src/main/java/dev/unexist/showcase/eventsplit/EventSplitProcessor.java	Tue Aug 17 11:31:42 2021 +0200
+++ b/event-split-extension-parent/deployment/src/main/java/dev/unexist/showcase/eventsplit/EventSplitProcessor.java	Wed Aug 18 08:19:00 2021 +0200
@@ -11,6 +11,8 @@
 
 package dev.unexist.showcase.eventsplit;
 
+import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
+import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
 
@@ -21,4 +23,9 @@
     FeatureBuildItem feature() {
         return new FeatureBuildItem(EVENT_SPLIT);
     }
+
+    @BuildStep
+    void build(BuildProducer<AdditionalBeanBuildItem> additionalBean) {
+        additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(EventSplitDispatcher.class));
+    }
 }
--- a/event-split-extension-parent/runtime/pom.xml	Tue Aug 17 11:31:42 2021 +0200
+++ b/event-split-extension-parent/runtime/pom.xml	Wed Aug 18 08:19:00 2021 +0200
@@ -33,6 +33,10 @@
         </dependency>
         <dependency>
             <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-smallrye-reactive-messaging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
             <artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
         </dependency>
 
--- a/event-split-extension-parent/runtime/src/main/java/dev/unexist/showcase/eventsplit/EventSplitDispatcher.java	Tue Aug 17 11:31:42 2021 +0200
+++ b/event-split-extension-parent/runtime/src/main/java/dev/unexist/showcase/eventsplit/EventSplitDispatcher.java	Wed Aug 18 08:19:00 2021 +0200
@@ -17,11 +17,9 @@
 import io.vertx.core.eventbus.EventBus;
 import org.apache.commons.lang3.StringUtils;
 import org.eclipse.microprofile.reactive.messaging.Channel;
-import org.eclipse.microprofile.reactive.messaging.Message;
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
-import java.util.concurrent.CompletionStage;
 
 @ApplicationScoped
 public class EventSplitDispatcher {
@@ -30,15 +28,18 @@
     @Inject
     EventBus bus;
 
+    EventSplitDispatcher() {
+        System.out.println("Init event dispatcher");
+    }
+
     @Channel("todo_in")
-    private CompletionStage<Void> dispatchEvents(Message message) {
-        String payload = (String) message.getPayload();
+    private void dispatchEvents(String message) {
         String typeName = StringUtils.EMPTY;
 
-        System.out.println("Handle message " + payload);
+        System.out.println("Handle message " + message);
 
         try {
-            JsonNode json = MAPPER.readTree(payload);
+            JsonNode json = MAPPER.readTree(message);
 
             typeName = json.get("type").asText();
         } catch (JsonProcessingException e) {
@@ -46,7 +47,5 @@
         }
 
         this.bus.send(typeName, message);
-
-        return message.ack();
     }
 }