Bird
Raised Fist0
Kafkadevops~20 mins

Event choreography vs orchestration in Kafka - Practice Questions

Choose your learning style10 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.

Practice

(1/5)
1. What is the main difference between event choreography and event orchestration in Kafka-based systems?
easy
A. Choreography lets services react independently; orchestration uses a central controller.
B. Choreography requires a central controller; orchestration lets services react independently.
C. Both use a central controller but differ in message format.
D. Choreography is synchronous; orchestration is asynchronous.

Solution

  1. Step 1: Understand event choreography

    Event choreography means each service listens and reacts to events on its own without a central manager.
  2. Step 2: Understand event orchestration

    Event orchestration means a central controller tells services what to do and when, managing the flow.
  3. Final Answer:

    Choreography lets services react independently; orchestration uses a central controller. -> Option A
  4. Quick Check:

    Choreography = independent reaction, Orchestration = central control [OK]
Hint: Choreography = no boss; orchestration = boss controls flow [OK]
Common Mistakes:
  • Confusing which uses a central controller
  • Thinking both require central control
  • Mixing synchronous and asynchronous concepts
2. Which Kafka component is typically used in event orchestration to coordinate services?
easy
A. Kafka Topics with independent consumers
B. A central orchestrator service producing commands
C. Kafka Connect for data integration
D. Kafka Streams for independent event processing

Solution

  1. Step 1: Identify orchestration role

    Orchestration needs a central service to control and send commands to other services.
  2. Step 2: Match Kafka components

    Kafka Topics and Streams are used for event flow, but orchestration requires a central orchestrator producing commands.
  3. Final Answer:

    A central orchestrator service producing commands -> Option B
  4. Quick Check:

    Orchestration = central orchestrator service [OK]
Hint: Orchestration needs a central command sender [OK]
Common Mistakes:
  • Choosing Kafka Topics as the controller
  • Confusing Kafka Connect with orchestration
  • Thinking Kafka Streams alone orchestrates
3. Given this Kafka event flow in choreography style:
Service A publishes event 'OrderCreated' to topic 'orders'.
Service B listens to 'orders' and publishes 'PaymentProcessed' to topic 'payments'.
Service C listens to 'payments' and updates inventory.

What happens if Service B fails to publish 'PaymentProcessed' event?
medium
A. Service C will not update inventory because it never receives the event.
B. Service C updates inventory anyway because it listens to 'orders'.
C. Service A retries publishing 'OrderCreated' event automatically.
D. A central orchestrator will resend 'PaymentProcessed' event.

Solution

  1. Step 1: Trace event flow in choreography

    Service A publishes 'OrderCreated', Service B reacts and publishes 'PaymentProcessed', Service C listens to 'payments'.
  2. Step 2: Analyze failure impact

    If Service B fails to publish 'PaymentProcessed', Service C never receives that event and cannot update inventory.
  3. Final Answer:

    Service C will not update inventory because it never receives the event. -> Option A
  4. Quick Check:

    Missing event means downstream service does not act [OK]
Hint: In choreography, missing event stops downstream actions [OK]
Common Mistakes:
  • Assuming Service C listens to 'orders' directly
  • Thinking Service A retries automatically
  • Expecting a central orchestrator in choreography
4. You have this orchestration code snippet controlling Kafka services:
orchestrator.sendCommand('ServiceB', 'ProcessPayment')
orchestrator.sendCommand('ServiceC', 'UpdateInventory')

But Service C updates inventory before Service B processes payment. What is the likely problem?
medium
A. Service C is ignoring commands from the orchestrator.
B. Service B is not subscribed to the correct Kafka topic.
C. Commands are sent asynchronously without waiting for Service B to finish.
D. Kafka topics are misconfigured causing message loss.

Solution

  1. Step 1: Understand orchestration command flow

    Orchestrator sends commands to services in order, expecting sequential execution.
  2. Step 2: Identify asynchronous issue

    If commands are sent asynchronously without waiting for Service B to complete, Service C may act too early.
  3. Final Answer:

    Commands are sent asynchronously without waiting for Service B to finish. -> Option C
  4. Quick Check:

    Orchestration needs ordered, awaited commands [OK]
Hint: Orchestration requires waiting for each command to finish [OK]
Common Mistakes:
  • Blaming Kafka topic subscription
  • Assuming Service C ignores commands
  • Thinking message loss causes order issue
5. You want to design a Kafka system for an online store where payment processing must strictly happen before inventory update, but you want to avoid a central orchestrator. Which approach fits best and how to ensure order?
hard
A. Use choreography but rely on manual retries to fix order issues.
B. Use event orchestration with a central controller sending commands in order to services.
C. Use orchestration but allow services to process events independently without waiting.
D. Use event choreography with services emitting events and consumers processing in sequence using Kafka partitions and consumer groups.

Solution

  1. Step 1: Identify requirement

    Payment must happen before inventory update, but no central orchestrator allowed.
  2. Step 2: Choose choreography with ordering

    Event choreography fits because services react independently. To ensure order, use Kafka partitions and consumer groups to process events in sequence.
  3. Final Answer:

    Use event choreography with services emitting events and consumers processing in sequence using Kafka partitions and consumer groups. -> Option D
  4. Quick Check:

    Choreography + Kafka ordering = correct sequence without central control [OK]
Hint: Choreography + Kafka partitions ensure order without central control [OK]
Common Mistakes:
  • Choosing orchestration despite no central controller allowed
  • Ignoring Kafka partition ordering
  • Relying on manual retries for order
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard