Complete the code to produce a command message to Kafka.
producer.send(new ProducerRecord<>("[1]", "CreateOrder", orderData));
The command messages are sent to the commands topic in CQRS.
Complete the code to consume events from Kafka for updating read models.
consumer.subscribe(Collections.singletonList("[1]"));
Event consumers listen to the events topic to update read models in CQRS.
Fix the error in the Kafka consumer group id for event processing.
props.put("group.id", "[1]");
The consumer group for event processing should be event-processors to separate concerns.
Fill both blanks to create a Kafka Streams topology that processes commands and produces events.
KStream<String, String> commands = builder.stream("[1]"); KStream<String, String> events = commands.mapValues(command -> [2]); events.to("events");
The stream reads from the commands topic and processes commands using processCommand(command) to produce events.
Fill all three blanks to implement a Kafka Streams processor that filters commands, maps them to events, and writes to the events topic.
KStream<String, String> commands = builder.stream("[1]"); KStream<String, String> filtered = commands.filter((key, value) -> value.contains("[2]")); filtered.mapValues(value -> [3]).to("events");
The code reads from the commands topic, filters commands containing CreateOrder, processes them with processCommand(value), and writes events.