TODO
authorKai Moritz <kai@juplo.de>
Wed, 13 Oct 2021 20:56:03 +0000 (22:56 +0200)
committerKai Moritz <kai@juplo.de>
Wed, 13 Oct 2021 20:56:03 +0000 (22:56 +0200)
src/main/java/de/juplo/kafka/wordcount/top10/Top10StreamProcessor.java

index 276ca8e..d30e5d7 100644 (file)
@@ -6,6 +6,7 @@ import de.juplo.kafka.wordcount.avro.Key;
 import de.juplo.kafka.wordcount.avro.Ranking;
 import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig;
 import io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde;
+import io.confluent.kafka.streams.serdes.avro.SpecificAvroSerializer;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.consumer.ConsumerConfig;
 import org.apache.kafka.common.serialization.Serdes;
@@ -13,6 +14,7 @@ import org.apache.kafka.streams.KafkaStreams;
 import org.apache.kafka.streams.KeyValue;
 import org.apache.kafka.streams.StreamsBuilder;
 import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.Consumed;
 import org.springframework.boot.SpringApplication;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.stereotype.Component;
@@ -43,7 +45,7 @@ public class Top10StreamProcessor
                StreamsBuilder builder = new StreamsBuilder();
 
                builder
-                               .<Key, Long>stream(properties.getInputTopic())
+                               .<Key, Long>stream(properties.getInputTopic(), Consumed.with(SpecificAvroSerializer.class, Serdes.String()) )
                                .map((key, count) -> new KeyValue<>(
                                                key.getUsername(),
                                                Entry.newBuilder().setWord(key.getWord()).setCount(count).build()))