How to write KTable in a Kafka topic? Like we use "to()" in KStreams how to do that for KTable?

Viewed 1558

As there is no "to()" method for KTable so do we need to always convert it to KStream before sending any message to a topic? Or how can we store a KTable in our topic?

2 Answers

Yes, in order to materialize a KTable to a topic, you're required to convert it to a regular stream (instead of a changelog stream) via table.toStream().to("myTopic").

Note that KTable had a to method some time ago.

In general, if you check older versions of KTable, like 1.0, you'll see that the API was simplified significantly and more than a dozen methods were deprecated, many of them deleted as of today, including to(): enter image description here

Related