Challenge - 5 Problems
Kafka Event Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of event choreography with Kafka consumers
Consider a Kafka setup where multiple microservices consume and produce events independently without a central coordinator. What will be the output sequence of events if Service A produces an event, and Services B and C react to it by producing their own events?
Kafka
Service A produces event 'start'. Service B listens for 'start' and produces 'B_done'. Service C listens for 'start' and produces 'C_done'. No central orchestrator is involved.
Attempts:
2 left
💡 Hint
Think about how independent consumers react to events without a central controller.
✗ Incorrect
In event choreography, services react independently to events. The order of 'B_done' and 'C_done' depends on which service processes the 'start' event first, so both orders are possible.
❓ Predict Output
intermediate2:00remaining
Output of event orchestration with Kafka
In an event orchestration model using Kafka, a central orchestrator service listens for events and commands other services. If the orchestrator receives 'start' and then commands Service B and Service C sequentially, what is the expected order of events?
Kafka
Orchestrator receives 'start'. Orchestrator sends command to Service B. Service B produces 'B_done'. Orchestrator waits for 'B_done' before commanding Service C. Service C produces 'C_done'.
Attempts:
2 left
💡 Hint
Consider how the orchestrator controls the flow by waiting for events before proceeding.
✗ Incorrect
The orchestrator commands Service B first and waits for 'B_done' before commanding Service C, so the events occur in a strict order.
🔧 Debug
advanced2:00remaining
Identify the error in Kafka event orchestration code snippet
Given the following Kafka consumer code snippet for an orchestrator, identify the error that would cause the orchestration to fail.
Kafka
def orchestrator_consumer(): for message in kafka_consumer: if message.key == 'start': kafka_producer.send('service_b_topic', b'command') elif message.key == 'B_done': kafka_producer.send('service_c_topic', b'command') elif message.key == 'C_done': print('Process complete') else: print('Unknown event')
Attempts:
2 left
💡 Hint
Check the syntax of conditional statements carefully.
✗ Incorrect
The else statement is missing a colon at the end, causing a SyntaxError.
🧠 Conceptual
advanced2:00remaining
Difference in failure handling between choreography and orchestration
In Kafka-based microservices, how does failure handling typically differ between event choreography and event orchestration?
Attempts:
2 left
💡 Hint
Think about who controls the flow and error management in each model.
✗ Incorrect
In choreography, each service handles its own errors and retries, leading to eventual consistency. Orchestration allows a central controller to manage errors and compensations.
❓ Predict Output
expert3:00remaining
Number of events produced in mixed choreography and orchestration
In a Kafka system, an orchestrator sends a 'start' command to Service A. Service A produces an event 'A_done' which triggers Service B and Service C independently (choreography). Service B produces 'B_done' and Service C produces 'C_done'. How many total events are produced including the initial command and all reactions?
Kafka
Orchestrator -> 'start' command Service A listens to 'start', produces 'A_done' Services B and C listen to 'A_done' and produce 'B_done' and 'C_done' respectively
Attempts:
2 left
💡 Hint
Count all events produced by orchestrator and services.
✗ Incorrect
The orchestrator produces 'start', Service A produces 'A_done', and Services B and C produce 'B_done' and 'C_done', totaling 4 events.