0
0
Kafkadevops~20 mins

Event choreography vs orchestration in Kafka - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Event Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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.
AEvents 'B_done' and 'C_done' are produced before 'start'.
BEvents in order: 'start', 'B_done', 'C_done' or 'start', 'C_done', 'B_done' depending on timing.
COnly 'start' event is produced; 'B_done' and 'C_done' are never produced.
DEvents in order: 'start', 'B_done', 'C_done' always in this fixed order.
Attempts:
2 left
💡 Hint
Think about how independent consumers react to events without a central controller.
Predict Output
intermediate
2: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'.
AEvents in order: 'start', 'B_done', 'C_done' always.
BOnly 'start' event is produced; no other events follow.
CEvents 'B_done' and 'C_done' produced simultaneously after 'start'.
DEvents in order: 'start', 'C_done', 'B_done' always.
Attempts:
2 left
💡 Hint
Consider how the orchestrator controls the flow by waiting for events before proceeding.
🔧 Debug
advanced
2: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')
ARuntimeError because kafka_producer is not defined.
BLogical error: orchestrator sends commands in wrong order.
CNo error; code runs correctly.
DSyntaxError due to missing colon after else statement.
Attempts:
2 left
💡 Hint
Check the syntax of conditional statements carefully.
🧠 Conceptual
advanced
2: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?
ABoth choreography and orchestration use the same failure handling mechanisms.
BChoreography uses centralized error handling; orchestration relies on local retries only.
CChoreography relies on local retries and eventual consistency; orchestration can implement centralized error handling and compensation.
DChoreography does not handle failures; orchestration ignores failures.
Attempts:
2 left
💡 Hint
Think about who controls the flow and error management in each model.
Predict Output
expert
3: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
A4 events: 'start', 'A_done', 'B_done', 'C_done'
B3 events: 'start', 'B_done', 'C_done'
C5 events: 'start', 'A_done', 'B_done', 'C_done', 'orchestrator_done'
D2 events: 'start' and 'A_done' only
Attempts:
2 left
💡 Hint
Count all events produced by orchestrator and services.