Bird
0
0

Which of the following is the correct way to add a persistent key-value state store named myStore to a StreamsBuilder in Kafka Streams?

easy📝 Syntax Q12 of 15
Kafka - Advanced Stream Processing
Which of the following is the correct way to add a persistent key-value state store named myStore to a StreamsBuilder in Kafka Streams?
Abuilder.addStateStore(Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("myStore"), Serdes.String(), Serdes.String()))
Bbuilder.addStore("myStore", persistentKeyValueStore())
Cbuilder.createStateStore("myStore", KeyValueStore.class)
Dbuilder.addKeyValueStore("myStore", Serdes.String(), Serdes.String())
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct syntax for adding state store and check options

    The correct method uses addStateStore with a store builder from Stores.keyValueStoreBuilder and Stores.persistentKeyValueStore. Only builder.addStateStore(Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("myStore"), Serdes.String(), Serdes.String())) matches the correct method signature and usage.
  2. Final Answer:

    builder.addStateStore(Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("myStore"), Serdes.String(), Serdes.String())) -> Option A
  3. Quick Check:

    Use addStateStore with keyValueStoreBuilder [OK]
Quick Trick: Use addStateStore with keyValueStoreBuilder [OK]
Common Mistakes:
  • Using incorrect method names like addStore or createStateStore
  • Missing Serdes parameters for key and value
  • Confusing persistent and in-memory store creation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes