query: 2.0.0 - (RED) The keys of the top10-topic are deserialized as JSON
[demos/kafka/wordcount] / src / main / java / de / juplo / kafka / wordcount / query / QueryStreamProcessor.java
index dcb1234..bf27e2d 100644 (file)
@@ -60,13 +60,15 @@ public class QueryStreamProcessor
                KTable<String, User> users = builder
                                .stream(
                                                usersInputTopic,
-                                               Consumed.with(null, new JsonSerde().copyWithType(User.class)))
+                                               Consumed.with(Serdes.String(), new JsonSerde().copyWithType(User.class)))
                                .toTable(
                                                Materialized
                                                                .<String, User>as(userStoreSupplier)
                                                                .withKeySerde(Serdes.String())
                                                                .withValueSerde(new JsonSerde().copyWithType(User.class)));
-               KStream<String, Ranking> rankings = builder.stream(rankingInputTopic);
+               KStream<String, Ranking> rankings = builder
+                               .<Key, Ranking>stream(rankingInputTopic)
+                               .map((key, value) -> new KeyValue<>(key.getUsername(), value));
 
                rankings
                                .join(users, (ranking, user) -> UserRanking.of(
@@ -76,6 +78,7 @@ public class QueryStreamProcessor
                                .toTable(
                                                Materialized
                                                                .<String, UserRanking>as(rankingStoreSupplier)
+                                                               .withKeySerde(Serdes.String())
                                                                .withValueSerde(new JsonSerde().copyWithType(UserRanking.class)));
 
                Topology topology = builder.build();