KTable: transforming one record into multiple records

Hello!

I want to create multiple records from the source record value of KTable.

How can I do this in kafka streams ^3.2?

Should I call toStream first and then use the flatMapValues method? Or is there another way to do it?

Hi @svyat,

Yes doing a myTable.toStream.flatMapValues will work provided you want to return a list.
If you want a little more flexibility you could also do a myTable.toStream.process(new MyProcessorSupplier()) using the KStream.process method and within the process method you can forward multiple records based whatever your code needs to do.

HTH

1 Like