From e2e7ed4987ac9fcabb313a948f022e98e9c9e0a7 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 27 Oct 2024 13:03:25 +0100 Subject: [PATCH] Die Counter werden mit dem ``String``-Key indiziert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Vorbereitung auf eine Poison-Pill Übung ist hier noch out-of-scope... --- src/main/java/de/juplo/kafka/ExampleConsumer.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/juplo/kafka/ExampleConsumer.java b/src/main/java/de/juplo/kafka/ExampleConsumer.java index 85b77b9..e400c4e 100644 --- a/src/main/java/de/juplo/kafka/ExampleConsumer.java +++ b/src/main/java/de/juplo/kafka/ExampleConsumer.java @@ -21,7 +21,7 @@ public class ExampleConsumer implements Runnable private final Thread workerThread; private final Runnable closeCallback; - private final Map counterState = new HashMap<>(); + private final Map counterState = new HashMap<>(); private volatile boolean running = false; private long consumed = 0; @@ -98,9 +98,8 @@ public class ExampleConsumer implements Runnable { consumed++; log.info("{} - {}: {}/{} - {}={}", id, offset, topic, partition, key, value); - Integer counted = Integer.parseInt(key); - Long counter = counterState.compute(counted, (k, v) -> v == null ? 1l : v + 1); - log.info("{} - current value for counter {}: {}", id, counted, counter); + Long counter = counterState.compute(key, (k, v) -> v == null ? 1l : v + 1); + log.info("{} - current value for counter {}: {}", id, key, counter); } -- 2.20.1