0

I've implemented a KTable and a KStream join in my application and expecting output messages in the following cases;

  1. A new message in KStream and there's a matching record in the KTable
  2. An updated message came in KStream and there's a matching record in the KTable
  3. When there's an update on a KTable record

I've been observing that my application does 1 and 2 as expected but not 3.

Is there any advice that I can get to achieve point 3?

Thanks!

J.GS.Han
  • 117
  • 1
  • 9

1 Answers1

0

You are looking for a table to table join. This triggers an output message when a new record arrives on either topic.

Start by ensuring that records you want to join across topics have the same key and are co-partitioned. Then read both topics as KTables.

KTable<String, Long> left = ...;
KTable<String, Double> right = ...;

Finally, perform a join on both tables

KTable<String, String> joined = left.join(right, (x, y) -> "left=" + x + ", right=" + y);

https://docs.confluent.io/platform/current/streams/javadocs/javadoc/org/apache/kafka/streams/kstream/KTable.html#join-org.apache.kafka.streams.kstream.KTable-org.apache.kafka.streams.kstream.ValueJoiner-

Skul
  • 303
  • 1
  • 6
  • 19