Bird
0
0

Given this pseudocode for an Outbox processor, what will be the output if the Outbox table has 3 unprocessed events?

medium📝 Analysis Q4 of 15
Microservices - Advanced Patterns
Given this pseudocode for an Outbox processor, what will be the output if the Outbox table has 3 unprocessed events?
events = db.query("SELECT * FROM outbox WHERE processed = false");
for event in events:
    publish(event);
    db.update("UPDATE outbox SET processed = true WHERE id = ?", event.id);
print("Processed events count:", len(events))
AProcessed events count: 1
BProcessed events count: 0
CProcessed events count: 3
DError: Cannot update processed flag
Step-by-Step Solution
Solution:
  1. Step 1: Analyze event selection

    The query selects all 3 unprocessed events from the Outbox table.
  2. Step 2: Understand processing loop

    Each event is published and marked processed, so all 3 are handled.
  3. Final Answer:

    Processed events count: 3 -> Option C
  4. Quick Check:

    Processed events count = 3 [OK]
Quick Trick: Loop processes all unprocessed events before printing count [OK]
Common Mistakes:
  • Assuming only one event is processed
  • Thinking processed count is zero before update
  • Expecting an error without reason

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes