0
0
Kafkadevops~10 mins

Interactive queries in Kafka - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a Kafka Streams application.

Kafka
KafkaStreams streams = new KafkaStreams(builder, [1]);
Drag options to blanks, or click blank then click option'
Aproperties
Bconfig
CstreamsConfig
Dsettings
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable name for configuration properties.
Passing an incorrect object type instead of Properties.
2fill in blank
medium

Complete the code to query the local state store named "counts-store".

Kafka
ReadOnlyKeyValueStore<String, Long> store = streams.store(StoreQueryParameters.fromNameAndType("counts-store", [1]));
Drag options to blanks, or click blank then click option'
AQueryableStoreTypes.timestampedKeyValueStore()
BQueryableStoreTypes.windowStore()
CQueryableStoreTypes.sessionStore()
DQueryableStoreTypes.keyValueStore()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong store type for querying.
Confusing window stores with key-value stores.
3fill in blank
hard

Fix the error in the code to get a value from the store by key.

Kafka
Long count = store.[1]("myKey");
Drag options to blanks, or click blank then click option'
Aget
Bfetch
Cretrieve
DgetValue
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like fetch or retrieve.
Confusing with other API methods.
4fill in blank
hard

Fill both blanks to create a queryable store parameter for a window store named "window-store".

Kafka
StoreQueryParameters<String, Long> params = StoreQueryParameters.fromNameAndType("window-store", [1]); // store type

QueryableStoreType<WindowStore<String, Long>> storeType = [2];
Drag options to blanks, or click blank then click option'
AQueryableStoreTypes.windowStore()
BQueryableStoreTypes.keyValueStore()
CQueryableStoreTypes.sessionStore()
DQueryableStoreTypes.timestampedKeyValueStore()
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing store types between key-value and window stores.
Using incorrect store type constants.
5fill in blank
hard

Fill all three blanks to create a map of key-value pairs from a store with a condition.

Kafka
Map<String, Long> result = new HashMap<>();
KeyValueIterator<String, Long> iter = store.all();
while (iter.hasNext()) {
    String key = iter.[1]().getKey();
    Long value = store.get(key);
    if (value [2] 10) {
        result.put(key, [3]);
    }
}
iter.close();
Drag options to blanks, or click blank then click option'
Aiterator
B>
Cvalue
Dnext
Attempts:
3 left
💡 Hint
Common Mistakes
Using iterator() instead of next() on the iterator.
Using wrong comparison operators.
Putting the wrong variable into the map.