Can we Convert KStream to Global KTable in Apache Kafka?

Viewed 1734

I am trying to work in scala for kafka streams. I am wondering if its possible to convert kafka streams to kafka global ktable? If Yes, HOW???

1 Answers

You cannot convert a kstream directly to globalKtable, but u can create one directly; refer kstreams for more detailed basics understanding.

For creating a globalKtable ;

val builder = new StreamsBuilder()
val globalMaterialized: Materialized[String, String, KeyValueStore[Bytes, Array[Byte]]] =
      Materialized.as("global_store_name").withKeySerde(Serdes.String).withValueSerde(Serdes.String)
builder.globalTable("topic_name", globalMaterialized)

Attach the GlobalKtable to processor for accessing it.

Related