Engineering notes
Event-Driven Architecture in Practice
Build event flows around durable publication, explicit contracts, duplicate-safe consumers and controlled replay. A broker is only one part of the design.
Event-driven architecture lets a producer publish a fact so other components can react without completing all downstream work in the original request. This can decouple processing and absorb bursts, but it moves complexity into delivery, state and recovery. A hypothetical OrderPlaced event illustrates the decisions that matter. Publishing an event is not the same as proving that every downstream action finished.
Choose events where delayed reaction is acceptable
An event states a fact that already happened; a command requests an action. OrderPlaced and ReserveStock therefore have different meanings and ownership. Name contracts accordingly and make pending states visible. If the user requires an immediate stock decision, an asynchronous event alone is not a substitute for an authoritative reservation operation.
Use events when several consumers need independent reactions, work can be deferred or the producer should not wait for every downstream system. A direct call may remain clearer for a simple request-response interaction. Event-driven architecture does not require event sourcing: a system can store current state and publish events without reconstructing its entire state from an event log.
Conceptual illustration of the topic; not an implementation diagram.
Write a contract that survives independent releases
Include a stable event identifier, event type, schema version, producer, occurrence time and the business entity identifier. Add an entity version when consumers need to detect gaps or stale updates. A correlation identifier connects diagnostics, while causation can explain which earlier event triggered this one. Specify delivery and retention expectations outside the payload too.
Prefer compatible additions and consumers that tolerate unknown fields. Removing or changing a field’s meaning needs an explicit migration policy. Minimize sensitive data: identifiers and a permitted lookup may be safer than copying a full customer record into a long-retained stream. The envelope below is illustrative, not a universal broker schema.
{
"event_id": "evt-example-001",
"type": "OrderPlaced",
"schema_version": 1,
"producer": "ordering",
"occurred_at": "2026-11-19T09:00:00Z",
"order_id": "order-example-42",
"aggregate_version": 1,
"correlation_id": "req-example-7"
}Publish durably with a transactional outbox
Updating a database and publishing to a broker are two writes. A crash between them can lose an event or announce a change that did not commit. Instead, commit the business row and an outbox row in the same local database transaction. A relay reads committed outbox entries and publishes them, using a deliberate polling or change-data-capture design.
A relay can crash after the broker accepts a message but before marking it published. Redelivery is therefore still possible. Monitor oldest unpublished entry, relay errors and backlog. Define cleanup and recovery procedures. Outbox solves a publication gap; it does not make every downstream action exactly once or remove the need to manage ordering.
Make consumers atomic and duplicate-safe
For a local database effect, insert a processed-event record under a unique constraint and apply the business change in the same transaction. Commit before acknowledging the message. A crash before acknowledgement causes redelivery, but the committed deduplication record prevents the effect from being repeated. Define how long those records must survive relative to replay and broker retention.
External effects such as sending a payment require a different boundary. Use the provider’s idempotency contract and a durable local operation state with reconciliation. Do not claim that a broker transaction covers an unrelated external API. Kafka’s exactly-once facilities apply within specific processing and transaction boundaries; they are not a blanket guarantee for arbitrary side effects.
Design ordering, retries and replay as explicit policies
Global ordering is often unnecessary and expensive. Identify the entity that needs ordered processing, choose an appropriate partition or routing key and preserve that guarantee through the consumer execution model. Parallel processing or a retry path can break application-level order even when the broker stores ordered messages. Decide how to handle gaps and stale versions.
Retry transient failures with bounded backoff. Quarantine poison messages with error context and an owner. A dead-letter destination is a diagnosis queue, not a completed recovery. Replay should specify the range, compatible schema, consumer version, rate and side-effect policy. Rebuilding a projection must not resend historical payments or customer notifications unintentionally.
Validate the business workflow across the whole pipeline
Measure publication lag, consumer lag, oldest pending work, failure rate and completion latency for the user operation. Test a relay crash after publication, a duplicate event, an out-of-order update, an unavailable consumer and replay after a schema change. Check that accepted work becomes completed or visibly unresolved.
Common mistakes are treating event publication as workflow completion, embedding excessive personal data, ignoring deduplication retention and claiming exactly-once delivery without a boundary. Use events to create useful independence, then make the resulting delay and recovery responsibilities explicit. If the workflow is easier to explain and operate with a direct call, keep that option.
References and further reading
Related content
Systems Integration and Business Workflow Automation
Connect your applications and automate repeatable processes with clear rules, visible status and a defined way to handle exceptions.
Backend Development, APIs and System Design
Backend systems, databases and APIs that connect your interfaces, apply business rules and keep information moving between the tools your team uses.
Designing Reliable Distributed Systems
Design for partial failure with explicit deadlines, bounded retries, durable idempotency, consistency choices and recovery procedures that can be tested.
Apply these decisions to your product
Describe the workload, current constraint and product goal to define the scope of a technical discussion.
Discuss your project
