Hello frens,
what is the best manner to publish KTable to Kafka?
Assume thath I’m streaming crypto currency trades and aggregating the prices to mean in KTable. Then I want to publish the KTable to Kafka. How to do this?
Should I map it to stream?
myKTable.toStream().to(myTopic);
or maybe its better to materialize it in the aggregation?
stream.groupByKey()
.windowedBy(TimeWindows.of(duration))
.aggregate(
() -> null,
new MeanPriceAggregator(duration),
Materialized.<String, MeanPrice, KeyValueStore<String, byte[]>>as(myTopic)
.with(stringSerde, meanPriceSerde))