Changeset 16:ed8e642353ca

Renamed adapters to adapter
author unexist
date Sat, 10 Apr 2021 16:02:46 +0200
parents d4f77f49eefb
children 48ee10ff9f61
files src/main/java/dev/unexist/showcase/todo/adapter/MessageResource.java src/main/java/dev/unexist/showcase/todo/adapter/TodoResource.java src/main/java/dev/unexist/showcase/todo/adapter/cdi/TodoCdiConsumer.java src/main/java/dev/unexist/showcase/todo/adapter/cloudevents/TodoCloudEventConsumer.java src/main/java/dev/unexist/showcase/todo/adapter/cloudevents/TodoCloudEventProducer.java src/main/java/dev/unexist/showcase/todo/adapter/smallrye/TodoSmallryeConsumer.java src/main/java/dev/unexist/showcase/todo/adapter/smallrye/TodoSmallryeProducer.java src/main/java/dev/unexist/showcase/todo/adapters/MessageResource.java src/main/java/dev/unexist/showcase/todo/adapters/TodoResource.java src/main/java/dev/unexist/showcase/todo/adapters/cdi/TodoCdiConsumer.java src/main/java/dev/unexist/showcase/todo/adapters/cloudevents/TodoCloudEventConsumer.java src/main/java/dev/unexist/showcase/todo/adapters/cloudevents/TodoCloudEventProducer.java src/main/java/dev/unexist/showcase/todo/adapters/smallrye/TodoSmallryeConsumer.java src/main/java/dev/unexist/showcase/todo/adapters/smallrye/TodoSmallryeProducer.java
diffstat 14 files changed, 482 insertions(+), 482 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/MessageResource.java	Sat Apr 10 16:02:46 2021 +0200
@@ -0,0 +1,93 @@
+/**
+ * @package Quarkus-Messaging-Showcase
+ *
+ * @file Todo resource
+ * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the GNU GPLv3.
+ * See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapters;
+
+import dev.unexist.showcase.todo.adapters.cdi.TodoCdiConsumer;
+import dev.unexist.showcase.todo.adapters.cloudevents.TodoCloudEventConsumer;
+import dev.unexist.showcase.todo.adapters.cloudevents.TodoCloudEventProducer;
+import dev.unexist.showcase.todo.adapters.smallrye.TodoSmallryeConsumer;
+import dev.unexist.showcase.todo.adapters.smallrye.TodoSmallryeProducer;
+import org.aerogear.kafka.SimpleKafkaProducer;
+import org.aerogear.kafka.cdi.annotation.Producer;
+import org.eclipse.microprofile.openapi.annotations.Operation;
+import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
+import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
+import org.eclipse.microprofile.openapi.annotations.tags.Tag;
+
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("/message")
+public class MessageResource {
+
+    /* Cdi */
+    @Producer
+    SimpleKafkaProducer<String, String> todoCdiProducer;
+
+    @Inject
+    TodoCdiConsumer todoCdiConsumer;
+
+    /* Cloudevents */
+    @Inject
+    TodoCloudEventProducer todoCloudEventProducer;
+
+    @Inject
+    TodoCloudEventConsumer todoCloudEventConsumer;
+
+    /* Smallrye */
+    @Inject
+    TodoSmallryeProducer todoSmallryeProducer;
+
+    @Inject
+    TodoSmallryeConsumer todoSmallryeConsumer;
+
+    @POST
+    @Operation(summary = "Send cdi event via kafka")
+    @Tag(name = "Message")
+    @APIResponses({
+            @APIResponse(responseCode = "204", description = "Nothing found"),
+            @APIResponse(responseCode = "500", description = "Server error")
+    })
+    public Response sendCdiEvent() {
+        this.todoCdiProducer.send("todos-cdi", "test", "test");
+
+        return Response.noContent().build();
+    }
+
+    @POST
+    @Operation(summary = "Send cloudevent via kafka")
+    @Tag(name = "Message")
+    @APIResponses({
+            @APIResponse(responseCode = "204", description = "Nothing found"),
+            @APIResponse(responseCode = "500", description = "Server error")
+    })
+    public Response sendCloudEvent() {
+        this.todoCloudEventProducer.send();
+
+        return Response.noContent().build();
+    }
+
+    @POST
+    @Operation(summary = "Send smallrye via kafka")
+    @Tag(name = "Message")
+    @APIResponses({
+            @APIResponse(responseCode = "204", description = "Nothing found"),
+            @APIResponse(responseCode = "500", description = "Server error")
+    })
+    public Response sendSmallryeEvent() {
+        this.todoSmallryeProducer.send();
+
+        return Response.noContent().build();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/TodoResource.java	Sat Apr 10 16:02:46 2021 +0200
@@ -0,0 +1,157 @@
+/**
+ * @package Quarkus-Messaging-Showcase
+ *
+ * @file Todo resource
+ * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the GNU GPLv3.
+ * See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapters;
+
+import dev.unexist.showcase.todo.domain.todo.Todo;
+import dev.unexist.showcase.todo.domain.todo.TodoBase;
+import dev.unexist.showcase.todo.domain.todo.TodoService;
+import org.eclipse.microprofile.openapi.annotations.Operation;
+import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
+import org.eclipse.microprofile.openapi.annotations.media.Content;
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
+import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
+import org.eclipse.microprofile.openapi.annotations.tags.Tag;
+
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+import java.util.Optional;
+
+@Path("/todo")
+public class TodoResource {
+
+    @Inject
+    TodoService todoService;
+
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Create new todo")
+    @Tag(name = "Todo")
+    @APIResponses({
+            @APIResponse(responseCode = "201", description = "Todo created"),
+            @APIResponse(responseCode = "406", description = "Bad data"),
+            @APIResponse(responseCode = "500", description = "Server error")
+    })
+    public Response create(TodoBase base) {
+        Response.ResponseBuilder response;
+
+        if (this.todoService.create(base)) {
+            response = Response.status(Response.Status.CREATED);
+        } else {
+            response = Response.status(Response.Status.NOT_ACCEPTABLE);
+        }
+
+        return response.build();
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Get all todos")
+    @Tag(name = "Todo")
+    @APIResponses({
+            @APIResponse(responseCode = "200", description = "List of todo", content =
+                @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Todo.class))),
+            @APIResponse(responseCode = "204", description = "Nothing found"),
+            @APIResponse(responseCode = "500", description = "Server error")
+    })
+    public Response getAll() {
+        List<Todo> todoList = this.todoService.getAll();
+
+        Response.ResponseBuilder response;
+
+        if (todoList.isEmpty()) {
+            response = Response.noContent();
+        } else {
+            response = Response.ok(Entity.json(todoList));
+        }
+
+        return response.build();
+    }
+
+    @GET
+    @Path("{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Get todo by id")
+    @Tag(name = "Todo")
+    @APIResponses({
+            @APIResponse(responseCode = "200", description = "Todo found", content =
+                @Content(schema = @Schema(implementation = Todo.class))),
+            @APIResponse(responseCode = "404", description = "Todo not found"),
+            @APIResponse(responseCode = "500", description = "Server error")
+    })
+    public Response findById(@PathParam("id") int id) {
+        Optional<Todo> result = this.todoService.findById(id);
+
+        Response.ResponseBuilder response;
+
+        if (result.isPresent()) {
+            response = Response.ok(Entity.json(result.get()));
+        } else {
+            response = Response.status(Response.Status.NOT_FOUND);
+        }
+
+        return response.build();
+    }
+
+    @PUT
+    @Path("{id}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Update todo by id")
+    @Tag(name = "Todo")
+    @APIResponses({
+            @APIResponse(responseCode = "204", description = "Todo updated"),
+            @APIResponse(responseCode = "404", description = "Todo not found"),
+            @APIResponse(responseCode = "500", description = "Server error")
+    })
+    public Response update(@PathParam("id") int id, TodoBase base) {
+        Response.ResponseBuilder response;
+
+        if (this.todoService.update(id, base)) {
+            response = Response.noContent();
+        } else {
+            response = Response.status(Response.Status.NOT_FOUND);
+        }
+
+        return response.build();
+    }
+
+    @DELETE
+    @Path("{id}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Delete todo by id")
+    @Tag(name = "Todo")
+    public Response delete(@PathParam("id") int id, TodoBase base) {
+        Response.ResponseBuilder response;
+
+        if (this.todoService.delete(id)) {
+            response = Response.noContent();
+        } else {
+            response = Response.status(Response.Status.NOT_FOUND);
+        }
+
+        return response.build();
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/cdi/TodoCdiConsumer.java	Sat Apr 10 16:02:46 2021 +0200
@@ -0,0 +1,31 @@
+/**
+ * @package Quarkus-Messaging-Showcase
+ *
+ * @file Todo cdi consumer
+ * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the GNU GPLv3.
+ * See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapters.cdi;
+
+import org.aerogear.kafka.cdi.annotation.Consumer;
+import org.aerogear.kafka.cdi.annotation.KafkaConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+@KafkaConfig(bootstrapServers = "localhost:9092")
+public class TodoCdiConsumer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TodoCdiConsumer.class);
+
+    @Consumer(topics = "topic-cdi", groupId = "todo-cdi-consumer")
+    public void onMessage(final String key, final String value) {
+        LOGGER.info("Key: {}", key);
+        LOGGER.info("Value: {}", value);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/cloudevents/TodoCloudEventConsumer.java	Sat Apr 10 16:02:46 2021 +0200
@@ -0,0 +1,62 @@
+/**
+ * @package Quarkus-Messaging-Showcase
+ *
+ * @file Todo cloudevent consumer
+ * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the GNU GPLv3.
+ * See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapters.cloudevents;
+
+import io.cloudevents.CloudEvent;
+import io.cloudevents.kafka.CloudEventDeserializer;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import java.time.Duration;
+import java.util.Collections;
+import java.util.Properties;
+
+@ApplicationScoped
+public class TodoCloudEventConsumer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TodoCloudEventConsumer.class);
+    private static final int POLL_IN_MILLIS = 100;
+
+    KafkaConsumer<String, CloudEvent> consumer;
+
+    TodoCloudEventConsumer() {
+        Properties props = new Properties();
+
+        props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
+        props.put(ConsumerConfig.GROUP_ID_CONFIG, "todo-ce-consumer");
+        props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+        props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, CloudEventDeserializer.class);
+        props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
+        props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
+
+        this.consumer = new KafkaConsumer<>(props);
+
+        consumer.subscribe(Collections.singletonList("todos-ce"));
+
+        LOGGER.info("Cloudevent consumer started");
+    }
+
+    public void receive() {
+        ConsumerRecords<String, CloudEvent> consumerRecords = consumer.poll(
+                Duration.ofMillis(POLL_IN_MILLIS));
+        consumerRecords.forEach(record -> {
+            LOGGER.info("Record key: {}", record.key());
+            LOGGER.info("Record value: {}", record.value().toString());
+            LOGGER.info("Record partition: {}", record.partition());
+            LOGGER.info("Record offset: {}", record.offset());
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/cloudevents/TodoCloudEventProducer.java	Sat Apr 10 16:02:46 2021 +0200
@@ -0,0 +1,79 @@
+/**
+ * @package Quarkus-Messaging-Showcase
+ *
+ * @file Todo cloudevent producer
+ * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the GNU GPLv3.
+ * See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapters.cloudevents;
+
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.message.Encoding;
+import io.cloudevents.jackson.JsonFormat;
+import io.cloudevents.kafka.CloudEventSerializer;
+import io.cloudevents.v03.CloudEventBuilder;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.clients.producer.RecordMetadata;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import java.net.URI;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+@ApplicationScoped
+public class TodoCloudEventProducer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TodoCloudEventConsumer.class);
+
+    private KafkaProducer<String, CloudEvent> producer;
+    private CloudEventBuilder eventBuilder;
+
+    TodoCloudEventProducer() {
+        Properties props = new Properties();
+
+        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
+        props.put(ProducerConfig.CLIENT_ID_CONFIG, "todo-cloudevents-producer");
+        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, CloudEventSerializer.class);
+        props.put(CloudEventSerializer.ENCODING_CONFIG, Encoding.STRUCTURED);
+        props.put(CloudEventSerializer.EVENT_FORMAT_CONFIG, JsonFormat.CONTENT_TYPE);
+
+        this.producer = new KafkaProducer<>(props);
+
+        this.eventBuilder = CloudEventBuilder.builder()
+                .withSource(URI.create("https://unexist.dev"))
+                .withType("todo");
+    }
+
+    public void send() {
+        try {
+            String id = UUID.randomUUID().toString();
+            String data = "Todo event";
+
+            CloudEvent event = this.eventBuilder
+                    .withId(id)
+                    .withData(data)
+                    .build();
+
+            RecordMetadata metadata = this.producer
+                    .send(new ProducerRecord<>("todos-ce", id, event))
+                    .get();
+
+            LOGGER.info("Record sent to partition {} with offset {}",
+                    metadata.partition(), metadata.offset());
+        } catch (InterruptedException | ExecutionException e) {
+            LOGGER.error("Error while trying to send the record", e);
+        }
+
+        this.producer.flush();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/smallrye/TodoSmallryeConsumer.java	Sat Apr 10 16:02:46 2021 +0200
@@ -0,0 +1,31 @@
+/**
+ * @package Quarkus-Messaging-Showcase
+ *
+ * @file Todo smallrye consumer
+ * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the GNU GPLv3.
+ * See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapters.smallrye;
+
+import org.eclipse.microprofile.reactive.messaging.Acknowledgment;
+import org.eclipse.microprofile.reactive.messaging.Incoming;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class TodoSmallryeConsumer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TodoSmallryeConsumer.class);
+
+    @Incoming("todos-rye-in")
+    @Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
+    public void receive(String value) {
+        LOGGER.info("Value: {}", value);
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/dev/unexist/showcase/todo/adapter/smallrye/TodoSmallryeProducer.java	Sat Apr 10 16:02:46 2021 +0200
@@ -0,0 +1,29 @@
+/**
+ * @package Quarkus-Messaging-Showcase
+ *
+ * @file Todo producer
+ * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
+ * @version $Id$
+ *
+ * This program can be distributed under the terms of the GNU GPLv3.
+ * See the file LICENSE for details.
+ **/
+
+package dev.unexist.showcase.todo.adapters.smallrye;
+
+import io.smallrye.mutiny.Multi;
+import org.eclipse.microprofile.reactive.messaging.Outgoing;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class TodoSmallryeProducer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TodoSmallryeConsumer.class);
+
+    @Outgoing("todo-rye-out")
+    public Multi<String> send() {
+        return Multi.createFrom().item("Todo");
+    }
+}
--- a/src/main/java/dev/unexist/showcase/todo/adapters/MessageResource.java	Wed Apr 07 13:00:28 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/**
- * @package Quarkus-Messaging-Showcase
- *
- * @file Todo resource
- * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
- * @version $Id$
- *
- * This program can be distributed under the terms of the GNU GPLv3.
- * See the file LICENSE for details.
- **/
-
-package dev.unexist.showcase.todo.adapters;
-
-import dev.unexist.showcase.todo.adapters.cdi.TodoCdiConsumer;
-import dev.unexist.showcase.todo.adapters.cloudevents.TodoCloudEventConsumer;
-import dev.unexist.showcase.todo.adapters.cloudevents.TodoCloudEventProducer;
-import dev.unexist.showcase.todo.adapters.smallrye.TodoSmallryeConsumer;
-import dev.unexist.showcase.todo.adapters.smallrye.TodoSmallryeProducer;
-import org.aerogear.kafka.SimpleKafkaProducer;
-import org.aerogear.kafka.cdi.annotation.Producer;
-import org.eclipse.microprofile.openapi.annotations.Operation;
-import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
-import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
-import org.eclipse.microprofile.openapi.annotations.tags.Tag;
-
-import javax.inject.Inject;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
-
-@Path("/message")
-public class MessageResource {
-
-    /* Cdi */
-    @Producer
-    SimpleKafkaProducer<String, String> todoCdiProducer;
-
-    @Inject
-    TodoCdiConsumer todoCdiConsumer;
-
-    /* Cloudevents */
-    @Inject
-    TodoCloudEventProducer todoCloudEventProducer;
-
-    @Inject
-    TodoCloudEventConsumer todoCloudEventConsumer;
-
-    /* Smallrye */
-    @Inject
-    TodoSmallryeProducer todoSmallryeProducer;
-
-    @Inject
-    TodoSmallryeConsumer todoSmallryeConsumer;
-
-    @POST
-    @Operation(summary = "Send cdi event via kafka")
-    @Tag(name = "Message")
-    @APIResponses({
-            @APIResponse(responseCode = "204", description = "Nothing found"),
-            @APIResponse(responseCode = "500", description = "Server error")
-    })
-    public Response sendCdiEvent() {
-        this.todoCdiProducer.send("todos-cdi", "test", "test");
-
-        return Response.noContent().build();
-    }
-
-    @POST
-    @Operation(summary = "Send cloudevent via kafka")
-    @Tag(name = "Message")
-    @APIResponses({
-            @APIResponse(responseCode = "204", description = "Nothing found"),
-            @APIResponse(responseCode = "500", description = "Server error")
-    })
-    public Response sendCloudEvent() {
-        this.todoCloudEventProducer.send();
-
-        return Response.noContent().build();
-    }
-
-    @POST
-    @Operation(summary = "Send smallrye via kafka")
-    @Tag(name = "Message")
-    @APIResponses({
-            @APIResponse(responseCode = "204", description = "Nothing found"),
-            @APIResponse(responseCode = "500", description = "Server error")
-    })
-    public Response sendSmallryeEvent() {
-        this.todoSmallryeProducer.send();
-
-        return Response.noContent().build();
-    }
-}
--- a/src/main/java/dev/unexist/showcase/todo/adapters/TodoResource.java	Wed Apr 07 13:00:28 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/**
- * @package Quarkus-Messaging-Showcase
- *
- * @file Todo resource
- * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
- * @version $Id$
- *
- * This program can be distributed under the terms of the GNU GPLv3.
- * See the file LICENSE for details.
- **/
-
-package dev.unexist.showcase.todo.adapters;
-
-import dev.unexist.showcase.todo.domain.todo.Todo;
-import dev.unexist.showcase.todo.domain.todo.TodoBase;
-import dev.unexist.showcase.todo.domain.todo.TodoService;
-import org.eclipse.microprofile.openapi.annotations.Operation;
-import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
-import org.eclipse.microprofile.openapi.annotations.media.Content;
-import org.eclipse.microprofile.openapi.annotations.media.Schema;
-import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
-import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
-import org.eclipse.microprofile.openapi.annotations.tags.Tag;
-
-import javax.inject.Inject;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.List;
-import java.util.Optional;
-
-@Path("/todo")
-public class TodoResource {
-
-    @Inject
-    TodoService todoService;
-
-    @POST
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    @Operation(summary = "Create new todo")
-    @Tag(name = "Todo")
-    @APIResponses({
-            @APIResponse(responseCode = "201", description = "Todo created"),
-            @APIResponse(responseCode = "406", description = "Bad data"),
-            @APIResponse(responseCode = "500", description = "Server error")
-    })
-    public Response create(TodoBase base) {
-        Response.ResponseBuilder response;
-
-        if (this.todoService.create(base)) {
-            response = Response.status(Response.Status.CREATED);
-        } else {
-            response = Response.status(Response.Status.NOT_ACCEPTABLE);
-        }
-
-        return response.build();
-    }
-
-    @GET
-    @Produces(MediaType.APPLICATION_JSON)
-    @Operation(summary = "Get all todos")
-    @Tag(name = "Todo")
-    @APIResponses({
-            @APIResponse(responseCode = "200", description = "List of todo", content =
-                @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Todo.class))),
-            @APIResponse(responseCode = "204", description = "Nothing found"),
-            @APIResponse(responseCode = "500", description = "Server error")
-    })
-    public Response getAll() {
-        List<Todo> todoList = this.todoService.getAll();
-
-        Response.ResponseBuilder response;
-
-        if (todoList.isEmpty()) {
-            response = Response.noContent();
-        } else {
-            response = Response.ok(Entity.json(todoList));
-        }
-
-        return response.build();
-    }
-
-    @GET
-    @Path("{id}")
-    @Produces(MediaType.APPLICATION_JSON)
-    @Operation(summary = "Get todo by id")
-    @Tag(name = "Todo")
-    @APIResponses({
-            @APIResponse(responseCode = "200", description = "Todo found", content =
-                @Content(schema = @Schema(implementation = Todo.class))),
-            @APIResponse(responseCode = "404", description = "Todo not found"),
-            @APIResponse(responseCode = "500", description = "Server error")
-    })
-    public Response findById(@PathParam("id") int id) {
-        Optional<Todo> result = this.todoService.findById(id);
-
-        Response.ResponseBuilder response;
-
-        if (result.isPresent()) {
-            response = Response.ok(Entity.json(result.get()));
-        } else {
-            response = Response.status(Response.Status.NOT_FOUND);
-        }
-
-        return response.build();
-    }
-
-    @PUT
-    @Path("{id}")
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    @Operation(summary = "Update todo by id")
-    @Tag(name = "Todo")
-    @APIResponses({
-            @APIResponse(responseCode = "204", description = "Todo updated"),
-            @APIResponse(responseCode = "404", description = "Todo not found"),
-            @APIResponse(responseCode = "500", description = "Server error")
-    })
-    public Response update(@PathParam("id") int id, TodoBase base) {
-        Response.ResponseBuilder response;
-
-        if (this.todoService.update(id, base)) {
-            response = Response.noContent();
-        } else {
-            response = Response.status(Response.Status.NOT_FOUND);
-        }
-
-        return response.build();
-    }
-
-    @DELETE
-    @Path("{id}")
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    @Operation(summary = "Delete todo by id")
-    @Tag(name = "Todo")
-    public Response delete(@PathParam("id") int id, TodoBase base) {
-        Response.ResponseBuilder response;
-
-        if (this.todoService.delete(id)) {
-            response = Response.noContent();
-        } else {
-            response = Response.status(Response.Status.NOT_FOUND);
-        }
-
-        return response.build();
-    }
-}
\ No newline at end of file
--- a/src/main/java/dev/unexist/showcase/todo/adapters/cdi/TodoCdiConsumer.java	Wed Apr 07 13:00:28 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/**
- * @package Quarkus-Messaging-Showcase
- *
- * @file Todo cdi consumer
- * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
- * @version $Id$
- *
- * This program can be distributed under the terms of the GNU GPLv3.
- * See the file LICENSE for details.
- **/
-
-package dev.unexist.showcase.todo.adapters.cdi;
-
-import org.aerogear.kafka.cdi.annotation.Consumer;
-import org.aerogear.kafka.cdi.annotation.KafkaConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.enterprise.context.ApplicationScoped;
-
-@ApplicationScoped
-@KafkaConfig(bootstrapServers = "localhost:9092")
-public class TodoCdiConsumer {
-    private static final Logger LOGGER = LoggerFactory.getLogger(TodoCdiConsumer.class);
-
-    @Consumer(topics = "topic-cdi", groupId = "todo-cdi-consumer")
-    public void onMessage(final String key, final String value) {
-        LOGGER.info("Key: {}", key);
-        LOGGER.info("Value: {}", value);
-    }
-}
\ No newline at end of file
--- a/src/main/java/dev/unexist/showcase/todo/adapters/cloudevents/TodoCloudEventConsumer.java	Wed Apr 07 13:00:28 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/**
- * @package Quarkus-Messaging-Showcase
- *
- * @file Todo cloudevent consumer
- * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
- * @version $Id$
- *
- * This program can be distributed under the terms of the GNU GPLv3.
- * See the file LICENSE for details.
- **/
-
-package dev.unexist.showcase.todo.adapters.cloudevents;
-
-import io.cloudevents.CloudEvent;
-import io.cloudevents.kafka.CloudEventDeserializer;
-import org.apache.kafka.clients.consumer.ConsumerConfig;
-import org.apache.kafka.clients.consumer.ConsumerRecords;
-import org.apache.kafka.clients.consumer.KafkaConsumer;
-import org.apache.kafka.common.serialization.StringDeserializer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.enterprise.context.ApplicationScoped;
-import java.time.Duration;
-import java.util.Collections;
-import java.util.Properties;
-
-@ApplicationScoped
-public class TodoCloudEventConsumer {
-    private static final Logger LOGGER = LoggerFactory.getLogger(TodoCloudEventConsumer.class);
-    private static final int POLL_IN_MILLIS = 100;
-
-    KafkaConsumer<String, CloudEvent> consumer;
-
-    TodoCloudEventConsumer() {
-        Properties props = new Properties();
-
-        props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
-        props.put(ConsumerConfig.GROUP_ID_CONFIG, "todo-ce-consumer");
-        props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
-        props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, CloudEventDeserializer.class);
-        props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
-        props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
-
-        this.consumer = new KafkaConsumer<>(props);
-
-        consumer.subscribe(Collections.singletonList("todos-ce"));
-
-        LOGGER.info("Cloudevent consumer started");
-    }
-
-    public void receive() {
-        ConsumerRecords<String, CloudEvent> consumerRecords = consumer.poll(
-                Duration.ofMillis(POLL_IN_MILLIS));
-        consumerRecords.forEach(record -> {
-            LOGGER.info("Record key: {}", record.key());
-            LOGGER.info("Record value: {}", record.value().toString());
-            LOGGER.info("Record partition: {}", record.partition());
-            LOGGER.info("Record offset: {}", record.offset());
-        });
-    }
-}
--- a/src/main/java/dev/unexist/showcase/todo/adapters/cloudevents/TodoCloudEventProducer.java	Wed Apr 07 13:00:28 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/**
- * @package Quarkus-Messaging-Showcase
- *
- * @file Todo cloudevent producer
- * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
- * @version $Id$
- *
- * This program can be distributed under the terms of the GNU GPLv3.
- * See the file LICENSE for details.
- **/
-
-package dev.unexist.showcase.todo.adapters.cloudevents;
-
-import io.cloudevents.CloudEvent;
-import io.cloudevents.core.message.Encoding;
-import io.cloudevents.jackson.JsonFormat;
-import io.cloudevents.kafka.CloudEventSerializer;
-import io.cloudevents.v03.CloudEventBuilder;
-import org.apache.kafka.clients.producer.KafkaProducer;
-import org.apache.kafka.clients.producer.ProducerConfig;
-import org.apache.kafka.clients.producer.ProducerRecord;
-import org.apache.kafka.clients.producer.RecordMetadata;
-import org.apache.kafka.common.serialization.StringSerializer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.enterprise.context.ApplicationScoped;
-import java.net.URI;
-import java.util.Properties;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-
-@ApplicationScoped
-public class TodoCloudEventProducer {
-    private static final Logger LOGGER = LoggerFactory.getLogger(TodoCloudEventConsumer.class);
-
-    private KafkaProducer<String, CloudEvent> producer;
-    private CloudEventBuilder eventBuilder;
-
-    TodoCloudEventProducer() {
-        Properties props = new Properties();
-
-        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
-        props.put(ProducerConfig.CLIENT_ID_CONFIG, "todo-cloudevents-producer");
-        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
-        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, CloudEventSerializer.class);
-        props.put(CloudEventSerializer.ENCODING_CONFIG, Encoding.STRUCTURED);
-        props.put(CloudEventSerializer.EVENT_FORMAT_CONFIG, JsonFormat.CONTENT_TYPE);
-
-        this.producer = new KafkaProducer<>(props);
-
-        this.eventBuilder = CloudEventBuilder.builder()
-                .withSource(URI.create("https://unexist.dev"))
-                .withType("todo");
-    }
-
-    public void send() {
-        try {
-            String id = UUID.randomUUID().toString();
-            String data = "Todo event";
-
-            CloudEvent event = this.eventBuilder
-                    .withId(id)
-                    .withData(data)
-                    .build();
-
-            RecordMetadata metadata = this.producer
-                    .send(new ProducerRecord<>("todos-ce", id, event))
-                    .get();
-
-            LOGGER.info("Record sent to partition {} with offset {}",
-                    metadata.partition(), metadata.offset());
-        } catch (InterruptedException | ExecutionException e) {
-            LOGGER.error("Error while trying to send the record", e);
-        }
-
-        this.producer.flush();
-    }
-}
--- a/src/main/java/dev/unexist/showcase/todo/adapters/smallrye/TodoSmallryeConsumer.java	Wed Apr 07 13:00:28 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/**
- * @package Quarkus-Messaging-Showcase
- *
- * @file Todo smallrye consumer
- * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
- * @version $Id$
- *
- * This program can be distributed under the terms of the GNU GPLv3.
- * See the file LICENSE for details.
- **/
-
-package dev.unexist.showcase.todo.adapters.smallrye;
-
-import org.eclipse.microprofile.reactive.messaging.Acknowledgment;
-import org.eclipse.microprofile.reactive.messaging.Incoming;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.enterprise.context.ApplicationScoped;
-
-@ApplicationScoped
-public class TodoSmallryeConsumer {
-    private static final Logger LOGGER = LoggerFactory.getLogger(TodoSmallryeConsumer.class);
-
-    @Incoming("todos-rye-in")
-    @Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
-    public void receive(String value) {
-        LOGGER.info("Value: {}", value);
-
-    }
-}
--- a/src/main/java/dev/unexist/showcase/todo/adapters/smallrye/TodoSmallryeProducer.java	Wed Apr 07 13:00:28 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/**
- * @package Quarkus-Messaging-Showcase
- *
- * @file Todo producer
- * @copyright 2020 Christoph Kappel <christoph@unexist.dev>
- * @version $Id$
- *
- * This program can be distributed under the terms of the GNU GPLv3.
- * See the file LICENSE for details.
- **/
-
-package dev.unexist.showcase.todo.adapters.smallrye;
-
-import io.smallrye.mutiny.Multi;
-import org.eclipse.microprofile.reactive.messaging.Outgoing;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.enterprise.context.ApplicationScoped;
-
-@ApplicationScoped
-public class TodoSmallryeProducer {
-    private static final Logger LOGGER = LoggerFactory.getLogger(TodoSmallryeConsumer.class);
-
-    @Outgoing("todo-rye-out")
-    public Multi<String> send() {
-        return Multi.createFrom().item("Todo");
-    }
-}