import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.common.serialization.Serdes;
import org.apache.kafka.streams.*;
-import org.apache.kafka.streams.kstream.Consumed;
import org.apache.kafka.streams.kstream.KStream;
import org.apache.kafka.streams.kstream.KTable;
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.JsonDeserializer;
import org.springframework.kafka.support.serializer.JsonSerde;
import java.net.URI;
-import java.util.Map;
import java.util.Optional;
import java.util.Properties;
{
StreamsBuilder builder = new StreamsBuilder();
- JsonSerde valueSerde = new JsonSerde();
- valueSerde.configure(Map.of(
- JsonDeserializer.TYPE_MAPPINGS,
- "user:" + Key.class.getName() + "," +
- "ranking:" + Ranking.class.getName() + "," +
- "userdata:" + User.class.getName() + "," +
- "userranking:" + UserRanking.class.getName()
- ), false);
- KTable<String, User> users = builder.table(
- usersInputTopic,
- Consumed.with(null, valueSerde.copyWithType(User.class))
- );
+ KTable<String, User> users = builder
+ .stream(usersInputTopic)
+ .toTable(Materialized.with(null, new JsonSerde().copyWithType(User.class)));
KStream<String, Ranking> rankings = builder.stream(rankingInputTopic);
rankings