Kafka Streams: Converting KStream to KTable
There are no methods in KStream to convert into a KTable. But there are workarounds to do that. They are as follows:
Write on a Kafka Topic and read back as Kable
We can also write to an intermediate Kafka Topic and read it back using StreamBuilder. Here is an example:
Perform a dummy aggregation
Here is an example we are converting a KStream to KTable using reduce method of KGroupedStream.
Please make sure to use specified Serde (s) for your key and value. I kept getting the following exception until I specified the exact Serde (s)
Ref: These techniques are actually discussed on Confluent.io blog. You can read in details here: