propertyMap.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, JsonSerde.class.getName());
propertyMap.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, JsonSerde.class.getName());
- propertyMap.put(JsonDeserializer.KEY_DEFAULT_TYPE, User.class.getName());
- propertyMap.put(JsonDeserializer.VALUE_DEFAULT_TYPE, Word.class.getName());
propertyMap.put(
JsonDeserializer.TYPE_MAPPINGS,
"user:" + User.class.getName() + "," +
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.streams.*;
-import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.Consumed;
import org.apache.kafka.streams.kstream.Materialized;
import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
import org.apache.kafka.streams.state.QueryableStoreTypes;
{
StreamsBuilder builder = new StreamsBuilder();
- KStream<User, Word> source = builder.stream(inputTopic);
-
- source
+ builder
+ .stream(
+ inputTopic,
+ Consumed.with(
+ new JsonSerde<>(User.class),
+ new JsonSerde<>(Word.class)))
.map((key, word) -> new KeyValue<>(word, word))
.groupByKey()
.count(