Ch. 10 · Microservices

Microservice Consumers and Duplicate Events

Microservice Consumers and Duplicate Events. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readbeginnerupdated Oct 3, 2026

At-least-once delivery makes duplicates normal. A consumer must coordinate its deduplication marker with the resulting side effect.

Before you start

You should understand HTTP, database transactions and the difference between one process and independently failing services. Draw the participants and message direction before choosing a pattern. Include timeout, duplicate delivery and recovery in the model instead of considering only successful requests.

The practical goal is to reason through this situation: Record the processed event ID in the same transaction as an account projection update. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Recognize repeated delivery

Treat duplicate event IDs as expected rather than exceptional.

Step 2: Coordinate local changes

Commit the processed marker with the projection change in one transaction.

Step 3: Protect remote effects separately

Use the destination’s idempotency contract for unrelated external operations.

Worked scenario

Record the processed event ID in the same transaction as an account projection update.

A consumer updates an account balance but crashes before storing a separate deduplication marker. Redelivery repeats the update. Putting both local changes in one transaction closes that gap; sending an external email or payment still lies outside that transaction and requires its own delivery strategy.

Common mistake

Checking a separate cache before writing can race or lose the marker independently.

Verify the behavior

Interrupt each boundary and redeliver the event; count logical effects.

Interview exercise

Protect an external side effect.

Answer and reasoning

Use the destination’s idempotency contract or a reliable operation record; a local marker alone cannot atomically cover an unrelated remote system.

Continue learning

Compare the scenario with the Microservices interview questions and test your understanding with the Microservices MCQs. For terminology and implementation details, consult the reference material.

More in Microservices

read ✓Microservices · hard

Microservices Anti-Corruption Layer

Protect a service's domain model from a foreign or legacy model with a translation layer at the boundary.

~2 min readread →
read ✓Microservices · hard

Microservices API Versioning and Evolution

Evolve service APIs without breaking consumers using additive changes, explicit versioning and consumer-driven contracts.

~2 min readread →
read ✓Microservices · hard

Microservices Backend for Frontend

Use a per-client BFF to aggregate services and shape responses, without letting it become a shared god service.

~2 min readread →
esc