0

I am trying to see how GlobalKtable works in kafka and for that i am trying to write sample code. I have created globalKtable but i want to see that too I have tried peek function but its not available, now i am trying by view but its giving compile time error.

what is the write way to see globalktable in scala?

what i have tried is

'''
 val genderGlobalTable: GlobalKTable[String, abc] = builder
        .globalTable(kafkaStreamConfig.getString("abc-topic"),
          Materialized.as("abcStore")
            .withKeySerde(stringSerde)
            .withValueSerde(abcSerde))
    
      implicit val streams: KafkaStreams = new KafkaStreams(builder.build(), properties)
    
      val view: ReadOnlyKeyValueStore[String, abc] = streams
        .store("abcStore", new QueryableStoreType[abc])

'''
Wajih
  • 93
  • 1
  • 10

1 Answers1

0

You cannot create an instance of QueryableStoreType that is an interface. Instead, you need to use the factory class QueryableStoreTypes (note, that the name is plural while the interface name is singular) to get the type you need.

For a GlobalKTable you can use QueryableStoreTypes.keyValueStore() (or depending on your Kafka Streams version, QueryableStoreTypes.timestampedKeyValueStore()).

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