Bird
0
0

Identify the error in this Kafka Streams interactive query code snippet:

medium📝 Debug Q14 of 15
Kafka - Advanced Stream Processing

Identify the error in this Kafka Streams interactive query code snippet:

var store = streams.store("ordersStore", ReadOnlyKeyValueStore.class);
var order = store.get(12345);
System.out.println(order);
APassing integer key instead of string key
BMissing try-catch block for exceptions
CUsing streams.store instead of streams.getStore
DIncorrect store type ReadOnlyKeyValueStore
Step-by-Step Solution
Solution:
  1. Step 1: Check method to get state store

    The method streams.store is correct.
  2. Step 2: Validate key type and store type

    Key type mismatch: passing integer 12345 instead of string key (common for ordersStore).
  3. Final Answer:

    Passing integer key instead of string key -> Option A
  4. Quick Check:

    Key type must match store definition [OK]
Quick Trick: Use correct key type in store.get(key) [OK]
Common Mistakes:
MISTAKES
  • Passing int literal without quotes for string keys
  • Assuming key type must be string always
  • Ignoring exception handling (not mandatory here)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes