counter: 1.2.2. - Simplified topology - better readability counter-1.2.2
authorKai Moritz <kai@juplo.de>
Thu, 16 Feb 2023 16:51:24 +0000 (17:51 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 17 Feb 2023 17:05:05 +0000 (18:05 +0100)
pom.xml
src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java
src/main/java/de/juplo/kafka/wordcount/counter/WordCount.java

diff --git a/pom.xml b/pom.xml
index f57c829..15a07c1 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
        </parent>
        <groupId>de.juplo.kafka.wordcount</groupId>
        <artifactId>counter</artifactId>
-       <version>1.2.1</version>
+       <version>1.2.2</version>
        <name>Wordcount-Counter</name>
        <description>Word-counting stream-processor of the multi-user wordcount-example</description>
        <properties>
index bccb253..4cc0c68 100644 (file)
@@ -63,7 +63,7 @@ public class CounterStreamProcessor
                                                                .noTypeInfo()))
                                .count(Materialized.as(storeSupplier))
                                .toStream()
-                               .map((word, count) -> new KeyValue<>(word, WordCount.of(word.getUser(), word.getWord(), count)))
+                               .map((word, count) -> new KeyValue<>(word, WordCount.of(word, count)))
                                .to(
                                                outputTopic,
                                                Produced.with(
index 44ccb2d..0767dd1 100644 (file)
@@ -9,4 +9,9 @@ public class WordCount
   String user;
   String word;
   long count;
+
+  public static WordCount of(Word word, long count)
+  {
+    return new WordCount(word.getUser(), word.getWord(), count);
+  }
 }