Complete the code to start a Kafka Streams application.
KafkaStreams streams = new KafkaStreams(builder, [1]);The KafkaStreams constructor requires a Properties object named config that contains the configuration settings.
Complete the code to query the local state store named "counts-store".
ReadOnlyKeyValueStore<String, Long> store = streams.store(StoreQueryParameters.fromNameAndType("counts-store", [1]));
The keyValueStore() type is used to query a key-value store in Kafka Streams.
Fix the error in the code to get a value from the store by key.
Long count = store.[1]("myKey");
fetch or retrieve.The correct method to get a value by key from a ReadOnlyKeyValueStore is get().
Fill both blanks to create a queryable store parameter for a window store named "window-store".
StoreQueryParameters<String, Long> params = StoreQueryParameters.fromNameAndType("window-store", [1]); // store type QueryableStoreType<WindowStore<String, Long>> storeType = [2];
Both blanks require the window store type, which is QueryableStoreTypes.windowStore().
Fill all three blanks to create a map of key-value pairs from a store with a condition.
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();
iterator() instead of next() on the iterator.The all() method returns an iterator, so we use next() to get keys. The condition checks if the value is greater than 10, and then puts the value into the result map.