Changeset 1:96011a00be30

Updated doc header
author unexist
date Fri, 30 Jul 2021 16:19:31 +0200
parents a0e15b59e560
children 6e2031ab7a90
files pom.xml src/main/java/dev/unexist/showcase/todo/adapter/TodoResource.java src/main/java/dev/unexist/showcase/todo/adapter/TodoSink.java src/main/java/dev/unexist/showcase/todo/domain/todo/DueDate.java src/main/java/dev/unexist/showcase/todo/domain/todo/Todo.java src/main/java/dev/unexist/showcase/todo/domain/todo/TodoBase.java src/main/java/dev/unexist/showcase/todo/domain/todo/TodoRepository.java src/main/java/dev/unexist/showcase/todo/domain/todo/TodoService.java src/main/java/dev/unexist/showcase/todo/infrastructure/persistence/ListTodoRepository.java src/main/java/dev/unexist/showcase/todo/infrastructure/serializer/DateSerializer.java src/test/java/dev/unexist/showcase/todo/application/TodoResourceTest.java
diffstat 11 files changed, 74 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/pom.xml	Fri Jul 30 13:31:55 2021 +0200
+++ b/pom.xml	Fri Jul 30 16:19:31 2021 +0200
@@ -3,7 +3,6 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
          xmlns="http://maven.apache.org/POM/4.0.0">
     <modelVersion>4.0.0</modelVersion>
-    <groupId>dev.unexist.showcase</groupId>
     <artifactId>showcase-eventbus-quarkus</artifactId>
     <version>0.1</version>
 
@@ -14,8 +13,26 @@
     </parent>
 
     <properties>
+        <smallrye-reactive.version>3.8.0</smallrye-reactive.version>
     </properties>
 
     <dependencies>
+        <!-- Quarkus -->
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-vertx</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
+        </dependency>
+
+        <!-- Testing -->
+        <dependency>
+            <groupId>io.smallrye.reactive</groupId>
+            <artifactId>smallrye-reactive-messaging-in-memory</artifactId>
+            <version>${smallrye-reactive.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
--- a/src/main/java/dev/unexist/showcase/todo/adapter/TodoResource.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/TodoResource.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Todo resource
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/TodoSink.java	Fri Jul 30 16:19:31 2021 +0200
@@ -0,0 +1,47 @@
+/**
+ * @package Quarkus-Kafka-Showcase
+ *
+ * @file Todo sink
+ * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the Apache License v2.0. See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapter;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import dev.unexist.showcase.todo.domain.todo.TodoBase;
+import dev.unexist.showcase.todo.domain.todo.TodoService;
+import org.eclipse.microprofile.reactive.messaging.Incoming;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+@ApplicationScoped
+public class TodoSink {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TodoSink.class);
+
+    @Inject
+    TodoService todoService;
+
+    private final ObjectMapper mapper = new ObjectMapper();
+
+    @Incoming("todo-sink")
+    public void consumeTodos(String json) {
+        TodoBase todo = null;
+
+        try {
+            todo = this.mapper.readValue(json, TodoBase.class);
+        } catch (JsonProcessingException e) {
+            LOGGER.error("Error reading JSON", e);
+        }
+
+        todoService.create(todo);
+    }
+}
+
+
--- a/src/main/java/dev/unexist/showcase/todo/domain/todo/DueDate.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/domain/todo/DueDate.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file DueDate class
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
--- a/src/main/java/dev/unexist/showcase/todo/domain/todo/Todo.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/domain/todo/Todo.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Todo class and aggregate root
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
--- a/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoBase.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoBase.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Todo base class
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
--- a/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoRepository.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoRepository.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Todo repository interface
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
--- a/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoService.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoService.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Todo service and domain service
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
@@ -13,7 +13,6 @@
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
-import javax.inject.Named;
 import java.util.List;
 import java.util.Optional;
 
--- a/src/main/java/dev/unexist/showcase/todo/infrastructure/persistence/ListTodoRepository.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/infrastructure/persistence/ListTodoRepository.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Todo repository
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
@@ -17,7 +17,6 @@
 import org.slf4j.LoggerFactory;
 
 import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Named;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
--- a/src/main/java/dev/unexist/showcase/todo/infrastructure/serializer/DateSerializer.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/infrastructure/serializer/DateSerializer.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Todo serializer
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>
--- a/src/test/java/dev/unexist/showcase/todo/application/TodoResourceTest.java	Fri Jul 30 13:31:55 2021 +0200
+++ b/src/test/java/dev/unexist/showcase/todo/application/TodoResourceTest.java	Fri Jul 30 16:19:31 2021 +0200
@@ -1,5 +1,5 @@
 /**
- * @package Showcase-Microstream-Helidon
+ * @package Showcase-Eventbus-Quarkus
  *
  * @file Stupid integration test
  * @copyright 2020-2021 Christoph Kappel <christoph@unexist.dev>