0
0
Kafkadevops~10 mins

CQRS pattern 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 produce a command message to Kafka.

Kafka
producer.send(new ProducerRecord<>("[1]", "CreateOrder", orderData));
Drag options to blanks, or click blank then click option'
Alogs
Bevents
Cqueries
Dcommands
Attempts:
3 left
💡 Hint
Common Mistakes
Using the events topic instead of commands.
Using queries topic for commands.
2fill in blank
medium

Complete the code to consume events from Kafka for updating read models.

Kafka
consumer.subscribe(Collections.singletonList("[1]"));
Drag options to blanks, or click blank then click option'
Aevents
Blogs
Cqueries
Dcommands
Attempts:
3 left
💡 Hint
Common Mistakes
Subscribing to commands topic instead of events.
Using queries topic for event consumption.
3fill in blank
hard

Fix the error in the Kafka consumer group id for event processing.

Kafka
props.put("group.id", "[1]");
Drag options to blanks, or click blank then click option'
Aevent-processors
Bquery-handlers
Ccommand-processors
Dlog-consumers
Attempts:
3 left
💡 Hint
Common Mistakes
Using command-processors group id for event consumers.
Using query-handlers group id for event consumers.
4fill in blank
hard

Fill both blanks to create a Kafka Streams topology that processes commands and produces events.

Kafka
KStream<String, String> commands = builder.stream("[1]");
KStream<String, String> events = commands.mapValues(command -> [2]);
events.to("events");
Drag options to blanks, or click blank then click option'
Acommands
Bevents
CprocessCommand(command)
DhandleEvent(command)
Attempts:
3 left
💡 Hint
Common Mistakes
Using events as input stream instead of commands.
Using handleEvent instead of processCommand for mapping.
5fill in blank
hard

Fill all three blanks to implement a Kafka Streams processor that filters commands, maps them to events, and writes to the events topic.

Kafka
KStream<String, String> commands = builder.stream("[1]");
KStream<String, String> filtered = commands.filter((key, value) -> value.contains("[2]"));
filtered.mapValues(value -> [3]).to("events");
Drag options to blanks, or click blank then click option'
Acommands
BCreateOrder
CprocessCommand(value)
Devents
Attempts:
3 left
💡 Hint
Common Mistakes
Filtering on wrong keyword.
Mapping with incorrect function.