2

I am using simply API of StreamsBuilder for building a GlobalKTable as this:

Materialized<Long, Category, KeyValueStore<Bytes, byte[]>> materialized =
    Materialized.<Long, Category, KeyValueStore<Bytes, byte[]>>as(this.categoryStoreName)
        .withCachingDisabled()
        .withKeySerde(Serdes.Long())
        .withValueSerde(CATEGORY_JSON_SERDE);

return streamsBuilder.globalTable(categoryTopic, materialized);

I would like to be notified by changes of it. It is rarely updated and in case an update I would like to trigger cache invalidation. What is the Kafka way of doing this?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Cemo
  • 5,370
  • 10
  • 50
  • 82

1 Answers1

3

GlobalKTable does not support this. However, you can use a "global store" and implement your custom Processor that will be called for each update.

Internally, a GlobalKTable uses a "global store" and provides the Processor implementation for you.

You can add a global store via StreamsBuilder#addGlobalStore().

Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137