Reputation: 31
KTable<key, Value1> table1
KTable<Key, Value2> table2
I am trying to join two KTables
(No windowing) by key and write the result as <Key,value1,value2>
to the output topic.
Could anybody help me to give some samples how to perform this operation.
Upvotes: 3
Views: 3246
Reputation: 2603
Because in KTable you always can have just one key and one value, you need to use some helper class to join your Value1 with Value2. You can use Pair<>
from javatuples library:
KTable<Key, Pair<Value1,Value2>> table3 =
table1.join(table2, (value1, value2) -> new Pair<Value1,Value2>(value1,value2));
to write it to topic, you need to implement own serde for Pair value and then:
table3.to(keySerde,pairSerde,"outputTopic")
Upvotes: 3