recorder: 1.1.1 - Updated Spring Boot to `3.2.5` recorder recorder-1.1.1
authorKai Moritz <kai@juplo.de>
Sun, 5 May 2024 09:12:26 +0000 (11:12 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 5 May 2024 10:43:57 +0000 (12:43 +0200)
Dockerfile
pom.xml
src/main/java/de/juplo/kafka/wordcount/recorder/RecorderApplication.java
src/main/java/de/juplo/kafka/wordcount/recorder/RecorderController.java
src/main/java/de/juplo/kafka/wordcount/recorder/Recording.java [new file with mode: 0644]

index 9c0b843..cb9ad4e 100644 (file)
@@ -1,4 +1,4 @@
-FROM openjdk:11-jre-slim
+FROM eclipse-temurin:17-jre
 COPY target/*.jar /opt/app.jar
 EXPOSE 8081
 ENTRYPOINT ["java", "-jar", "/opt/app.jar"]
diff --git a/pom.xml b/pom.xml
index 44a6cd1..4e87c6e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
        <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
-               <version>3.0.2</version>
+               <version>3.2.5</version>
                <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>de.juplo.kafka.wordcount</groupId>
        <artifactId>recorder</artifactId>
-       <version>1.0.2</version>
+       <version>1.1.1</version>
        <name>Wordcount-Recorder</name>
        <description>Recorder-service of the multi-user wordcount-example</description>
        <properties>
@@ -26,8 +26,8 @@
                        <artifactId>spring-boot-starter-web</artifactId>
                </dependency>
                <dependency>
-                       <groupId>org.apache.kafka</groupId>
-                       <artifactId>kafka-clients</artifactId>
+                       <groupId>org.springframework.kafka</groupId>
+                       <artifactId>spring-kafka</artifactId>
                </dependency>
                <dependency>
                        <groupId>org.hibernate.validator</groupId>
index abe0685..11248d8 100644 (file)
@@ -17,7 +17,7 @@ import java.util.Properties;
 public class RecorderApplication
 {
        @Bean(destroyMethod = "close")
-       KafkaProducer<String, String> producer(RecorderApplicationProperties properties)
+       KafkaProducer<String, Recording> producer(RecorderApplicationProperties properties)
        {
                Assert.hasText(properties.getBootstrapServer(), "juplo.wordcount.recorder.bootstrap-server must be set");
 
index f7e32e2..c9d2109 100644 (file)
@@ -18,10 +18,12 @@ import jakarta.validation.constraints.NotEmpty;
 public class RecorderController
 {
   private final String topic;
-  private final KafkaProducer<String, String> producer;
+  private final KafkaProducer<String, Recording> producer;
 
 
-  public RecorderController(RecorderApplicationProperties properties, KafkaProducer<String,String> producer)
+  public RecorderController(
+      RecorderApplicationProperties properties,
+      KafkaProducer<String,Recording> producer)
   {
     this.topic = properties.getTopic();
     this.producer = producer;
@@ -44,7 +46,11 @@ public class RecorderController
   {
     DeferredResult<ResponseEntity<RecordingResult>> result = new DeferredResult<>();
 
-    ProducerRecord<String, String> record = new ProducerRecord<>(topic, username, sentence);
+    ProducerRecord<String, Recording> record = new ProducerRecord<>(
+        topic,
+        username,
+        Recording.of(username, sentence));
+
     producer.send(record, (metadata, exception) ->
     {
       if (metadata != null)
diff --git a/src/main/java/de/juplo/kafka/wordcount/recorder/Recording.java b/src/main/java/de/juplo/kafka/wordcount/recorder/Recording.java
new file mode 100644 (file)
index 0000000..6117438
--- /dev/null
@@ -0,0 +1,11 @@
+package de.juplo.kafka.wordcount.recorder;
+
+import lombok.Value;
+
+
+@Value(staticConstructor = "of")
+public class Recording
+{
+  String user;
+  String sentence;
+}