Core Concepts
Event-Driven Architecture
Publish a business fact that other services can act on, then decide what they do when delivery is late, repeated, or missing.
In an event-driven architecture, a service publishes a fact about something that happened. Other services receive that event and decide independently how to act on it. This lets the service that saves an order finish while fulfillment and notifications handle the event on their own schedules. Azure Architecture Center on event producers and consumers
Define what happened and who owns it
When the Orders service accepts order O42, it saves the order and records an event called OrderPlaced. The order page can then show Awaiting fulfillment. The warehouse outcome is still pending.
A command asks something to act. A request to place the order is a command. A command called ReserveStock asks the Inventory service to make a reservation, which it can accept or deny. An event reports a fact, such as OrderPlaced. Fulfillment can subscribe to that fact and decide whether to request a reservation.
Use a small, deliberate event contract.
{
"source": "orders",
"eventId": "E51",
"type": "OrderPlaced",
"schemaVersion": 1,
"orderId": "O42",
"orderVersion": 8
}eventId identifies this occurrence within its source. A repeat of E51 keeps the same identity. orderVersion says where this change sits in O42's history. schemaVersion describes the event's fields and meaning. Keep those three jobs separate. If the event needs facts as they were at placement time, include them or let the consumer read that specific version. A later lookup of the current order can return a different state. CloudEvents on source and event identity
Give subscribers their own progress
In one database transaction, Orders saves the change and records E51 in an outbox, a table of messages it owes to subscribers. A separate process reads the committed event and publishes it to a broker, a service that delivers messages to subscribers. Fulfillment and Notifications have separate subscriptions. Fulfillment can create its task while Notifications retries its own failed work. Orders still owns the order, and each subscriber owns the state it updates.
A durable subscription needs a place to resume after an outage. Select a delivery mechanism that can retain obligations for the time they need to survive. Track the oldest waiting event separately for Fulfillment and Notifications. A rising backlog tells us where work is falling behind, even when Orders can still accept checkout requests.
Recover repeats where the effect happens
Suppose Fulfillment receives E51 twice. It can use a uniqueness rule to record the event identity and create the task in the same local transaction. It acknowledges delivery after that commit. If it crashes before acknowledging, the broker can send E51 again. The recorded identity lets the new worker acknowledge the repeat while keeping one task. Give the task a stable identity for initial fulfillment of O42 and enforce its uniqueness in the Fulfillment store separately from the event ID. A repair can use the same task identity even when it has a different event ID.
A call to an external email provider has another boundary. Saving E51 in the notification database cannot tell us whether an earlier attempt reached the provider. Use an operation ID the provider will recognize, or check an authoritative outcome before trying again. A timeout can leave the effect unknown. The system needs a way to record and resolve that uncertainty. Idempotency · AWS on safe retries
Decide which changes need an order
Orders then accepts a cancellation and publishes OrderCancelled for O42 at version 9. A subscriber might see version 9 before version 8 during retries or a replay from another path.
A dashboard view that already has the complete version 9 state can ignore the earlier placed state. Its job is to show where the order stands now. A workflow that needs a distinct effect for every event must recover missing needed changes before it advances. An apparent version gap only proves an event is missing if the subscriber's feed promises that all relevant versions are present.
A version guard on a view also has a limit. If the product promises that a cancelled order cannot start picking, the service that controls picking has to enforce that condition when it accepts the work. Otherwise a worker can act on a previously valid view after the order changes. Make the transition and its authority part of the business design.
Compare with the source of truth
A durable subscriber can replay while it still has the required event history. There can still be a lasting gap. Suppose a configuration error stops Fulfillment from receiving E51 and the event ages out before anyone notices.
A reconciliation job compares the authority with the actual downstream state. It finds O42 is still awaiting fulfillment and there is no task in the Fulfillment store. The repair requests the task with the same logical task identity the ordinary event path uses. If E51 arrives late or the repair runs twice, that business identity still prevents a second task. The repair checks for cancellation when it scans. The service that controls picking still enforces the cancellation rule when it accepts work, because the order can change after the scan.
Comparing current records can repair a current missing task. To recover an event that represents an earlier obligation, such as a payment action that must be audited, keep the authoritative history required to identify it. Track the number and age of unresolved mismatches as well as subscriber lag.
Decide what stays on the request path
Accepting the order and creating the warehouse task can be separate when the customer sees the work is pending. If the response promises that stock has already been reserved, make the reservation decision before that response. For work with an explicitly lower delivery requirement, such as optional click analytics, the request can continue even when a bounded delivery buffer fills.
In an interview, name the owner, the fact it can publish, and one subscriber's completion rule. Then trace a duplicate and a missing delivery. Those two cases tell us which state and history the design needs to keep.
See also
- Messaging and Work Queues compares handing work to a worker with sending one fact to several subscribers.
- Idempotency traces how retries reach the system that owns the effect.
- Consistency Models explains what a user can observe while a downstream view catches up.
- Transactional Outbox keeps event publication tied to the source commit.
- Change Data Capture follows committed row changes from a source database.
Used in
- URL Shortener moves click analytics off the redirect path and counts deliberate drops after its bounded buffer fills.
- Group Chat with Threads sends live delivery notifications and uses saved messages or inbox state to recover missed delivery.
- Batched Inference Service separates acceptance from later processing and applies duplicate protection at the result store.
Done reading? Mark it so it sticks in your dashboard.