0
0
Kafkadevops~10 mins

State stores 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 create a persistent state store named "my-store".

Kafka
StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore([1]), Serdes.String(), Serdes.String());
Drag options to blanks, or click blank then click option'
A"state-store"
B"store"
C"my-store"
D"kafka-store"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the store name in quotes.
Using an incorrect store name.
2fill in blank
medium

Complete the code to add the state store to the topology.

Kafka
topology.[1](storeBuilder);
Drag options to blanks, or click blank then click option'
AaddStateStore
BaddProcessor
CaddSource
DaddSink
Attempts:
3 left
💡 Hint
Common Mistakes
Using addProcessor instead of addStateStore.
Confusing addSource or addSink with state store methods.
3fill in blank
hard

Fix the error in the code to retrieve the state store from the processor context.

Kafka
KeyValueStore<String, String> store = (KeyValueStore<String, String>) context.[1]("my-store");
Drag options to blanks, or click blank then click option'
AfetchStateStore
BretrieveStore
CgetStore
DgetStateStore
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names that do not exist in the API.
Forgetting to cast the returned object to KeyValueStore.
4fill in blank
hard

Fill both blanks to create a RocksDB persistent key-value store with string serializers.

Kafka
StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.[1]KeyValueStore("my-rocks-store"), [2], Serdes.String());
Drag options to blanks, or click blank then click option'
Apersistent
BinMemory
CSerdes.String()
DpersistentRocksDB
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inMemory' instead of 'persistent' for the store type.
Using wrong serializer for the key.
5fill in blank
hard

Fill all three blanks to define a state store, add it to the topology, and retrieve it in a processor.

Kafka
StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.[1]KeyValueStore("store1"), Serdes.String(), [2]);

topology.[3](storeBuilder);
Drag options to blanks, or click blank then click option'
Apersistent
BSerdes.String()
CaddStateStore
DinMemory
Attempts:
3 left
💡 Hint
Common Mistakes
Using inMemory instead of persistent store.
Using wrong serializer for values.
Using addProcessor instead of addStateStore.