From: Kai Moritz Date: Wed, 5 Jun 2024 21:57:32 +0000 (+0200) Subject: counter: 1.3.0 - (GREEN) Fixed the typing for the state-store X-Git-Tag: popular-on-counter~5 X-Git-Url: https://juplo.de/gitweb/?a=commitdiff_plain;h=98f4de98c6c3f527496d85b5e32fef0a3a23cbd5;p=demos%2Fkafka%2Fwordcount counter: 1.3.0 - (GREEN) Fixed the typing for the state-store --- diff --git a/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java b/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java index fd5c5a7..64bd619 100644 --- a/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java +++ b/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java @@ -7,6 +7,7 @@ import org.apache.kafka.streams.kstream.Materialized; import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier; import org.apache.kafka.streams.state.QueryableStoreTypes; import org.apache.kafka.streams.state.ReadOnlyKeyValueStore; +import org.springframework.kafka.support.serializer.JsonSerde; import java.util.Properties; @@ -46,7 +47,10 @@ public class CounterStreamProcessor source .map((key, word) -> new KeyValue<>(word, word)) .groupByKey() - .count(Materialized.as(storeSupplier)) + .count( + Materialized + .as(storeSupplier) + .withKeySerde(new JsonSerde<>().copyWithType(Word.class).forKeys())) .toStream() .map((word, counter) -> new KeyValue<>(word, WordCounter.of(word, counter))) .to(outputTopic);