0
0
Kafkadevops~10 mins

Stream topology 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 stream builder instance.

Kafka
StreamsBuilder builder = new [1]();
Drag options to blanks, or click blank then click option'
AStreamsBuilder
BKafkaStreams
CStreamConfig
DTopology
Attempts:
3 left
💡 Hint
Common Mistakes
Using KafkaStreams instead of StreamsBuilder.
Using Topology directly without builder.
2fill in blank
medium

Complete the code to define a source stream from a topic named 'input-topic'.

Kafka
KStream<String, String> source = builder.stream([1]);
Drag options to blanks, or click blank then click option'
A"output-topic"
B"input-topic"
Cinput-topic
Dsource-topic
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the topic name.
Using the wrong topic name.
3fill in blank
hard

Fix the error in the code to send the processed stream to an output topic.

Kafka
processedStream.to([1]);
Drag options to blanks, or click blank then click option'
A"output-topic"
BoutputTopic
Coutput-topic
DprocessedStream
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable name without quotes.
Passing the stream variable itself.
4fill in blank
hard

Fill both blanks to build and start the Kafka Streams application.

Kafka
Topology topology = builder.[1]();
KafkaStreams streams = new KafkaStreams(topology, [2]);
streams.start();
Drag options to blanks, or click blank then click option'
Abuild
Bstart
Cprops
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using start() instead of build() on builder.
Passing config instead of props.
5fill in blank
hard

Fill all three blanks to create a stream, filter messages with value length > 5, and send to 'filtered-topic'.

Kafka
KStream<String, String> stream = builder.stream([1]);
KStream<String, String> filtered = stream.filter((key, value) -> value.[2]() > [3]);
filtered.to("filtered-topic");
Drag options to blanks, or click blank then click option'
A"input-topic"
Blength
C5
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using size() instead of length() for strings.
Not quoting the topic name.