Markdown Editor

Event-Driven Architecture Design Template (AsyncAPI 3.1, CloudEvents)

Business events, event types, broker topology, topic naming and partitions, event catalogue, CloudEvents envelope, schema compatibility, outbox and CDC, replay

आर्किटेक्चरपूर्णAsyncAPI 3.1.0; CloudEvents 1.0.2eventdrivendesign
एडिटर में खोलें.md डाउनलोड करें

उपयोग कैसे करें: Use it when several domains publish and consume events and need shared rules and shared broker infrastructure. Fill event semantics, topic naming, the envelope and the default schema compatibility mode first, before the first production topic. The main pitfall is letting raw CDC row events or commands disguised as events cross domain boundaries.

प्रीव्यू

Event-Driven Architecture Design: [Solution or domain landscape name]

Solution-level design for an event-driven architecture that spans many producers, consumers and event APIs: business events and domains, event types and their semantics, broker topology and clusters, topic and channel naming, partitioning, the event catalogue, envelope and schema registry with compatibility modes, delivery, ordering and idempotency, the transactional outbox and change data capture, retention and replay, security and access control, observability and lineage, governance and capacity. Contracts follow the AsyncAPI Specification 3.1.0 and the CloudEvents 1.0.2 envelope; pattern names follow Enterprise Integration Patterns. Replace every [bracketed] value and every row marked Example.

Document control

FieldValue
Document ID[EDA-001]
Landscape or programme[Name]
Broker estate[Product and clusters covered]
Version[0.1]
Status[Draft / In review / Approved / Superseded]
Owner[@eda-lead]
Approvers/reviewers[@chief-architect], [@platform-lead], [@security-architect], [@data-governance-lead]
Classification[Internal / Confidential]
Last updatedYYYY-MM-DD
Related documents[Integration strategy], [Event API specifications], [Event storming summary]

Approvals

RoleNameDecisionDate
Chief architect[@name][Approve / Approve with conditions / Reject]YYYY-MM-DD
Platform owner[@name][Decision]YYYY-MM-DD
Security[@name][Decision]YYYY-MM-DD
Data governance[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft
1.0YYYY-MM-DD[@name]Example: Approved; CloudEvents envelope and BACKWARD_TRANSITIVE default adopted
1.1YYYY-MM-DD[@name]Example: Added a second region with topic mirroring

Contents

1. Scope, drivers and context

1.1 Drivers

IDDriverWhy events
EDR-001 (Example)Stock must be visible to every channel within secondsOne stock change fans out to many consumers without the WMS knowing them
EDR-002 (Example)Order processing must survive downstream outagesConsumers catch up from the log after recovery
EDR-003 (Example)New consumers (fraud, analytics, loyalty) are added every quarterSubscribing does not require a change to the producer
[EDR-NNN][Driver][Why events]

1.2 Scope

In scopeOut of scope
Example: Business events between order, payment, fulfilment, stock and customer domainsRequest and response APIs (see API Design Guidelines, architecture/api-design-guidelines)
Example: Change events from the ERP and the WMSStreaming analytics jobs (see Streaming Solution Design, architecture/streaming-solution-design)
Example: Outbound partner webhooks fed from internal eventsWebhook delivery platform internals (system-design/design-webhook-delivery)
[Item][Item]

1.3 Context

The context view shows producers, the broker estate and the main consumers for the worked example.

2. Business events and domains

DomainOwning teamKey business eventsSystem of record
Order (Example)@team-orderOrderPlaced, OrderCancelled, OrderCompletedOrder service
Payment (Example)@team-paymentPaymentAuthorised, PaymentCaptured, RefundIssuedPayment service
Fulfilment (Example)@team-fulfilmentShipmentDispatched, ShipmentDeliveredWMS
Stock (Example)@team-stockStockLevelChanged, StockReservedWMS and ERP
Customer (Example)@team-customerCustomerRegistered, CustomerConsentChangedCRM
[Domain][@team][Events][System]

Rules for business events:

  • Name each event as a past-tense fact in the language of the domain.
  • One owning domain per event type; only the owner publishes it.
  • An event describes what happened, not what a consumer should do.
  • Publish an event only after the change it describes is committed.

3. Event types and semantics

KindMeaningPayloadConsumersExample
Event notificationSomething happened; fetch details if neededIdentifiers and minimal factsMany, unknown to producerExample: OrderPlaced with order ID and total
Event-carried state transferSomething happened and here is the new stateFull or partial entity stateMany; can build local read modelsExample: StockLevelChanged with SKU, location, quantity
Domain event (internal)Fact inside one bounded contextDomain model, may change oftenSame domain onlyExample: Internal pricing rule applied
Integration event (public)Fact published across domain boundariesStable public contractOther domainsExample: PaymentCaptured
CommandRequest to one receiver to do somethingInstruction and parametersOne known receiverExample: ReserveStock on a queue
Change event (CDC)Row-level change in a databaseBefore and after imagesSame domain or translation stepExample: inventory table update

Rules:

IDRule
EVR-001 (Example)Only integration events and commands cross domain boundaries; domain events and raw change events stay inside the owning domain
EVR-002 (Example)Commands use point-to-point channels with exactly one consumer group; events use publish-subscribe channels
EVR-003 (Example)Prefer event-carried state transfer for entities that consumers cache; prefer notification for large or sensitive entities
EVR-004 (Example)Never put a reply expectation inside an event; use a request and reply pattern with correlation IDs if a reply is needed
[EVR-NNN][Rule]

4. Broker topology

ClusterPurposeRegion and zonesTenancyReplication
prod-core (Example)Business events and commands[Region 1], three zonesShared by domains, quotas per domainReplication factor 3, minimum in-sync replicas 2
prod-cdc (Example)Raw change events and connectors[Region 1], three zonesPlatform team onlyReplication factor 3
prod-dr (Example)Disaster recovery copy of prod-core[Region 2]Read only until failoverAsynchronous topic mirroring
nonprod (Example)Development and test[Region 1]SharedReplication factor 3, shorter retention
[Cluster][Purpose][Region][Tenancy][Replication]

Decisions to record: managed service or self-run, cross-region model (active and passive, or active and active with per-region topics), expected recovery point (mirroring lag) and recovery time, and how consumer offsets are translated on failover. Link the tiering to Resilience Tiering and HA/DR Design (architecture/resilience-tiering-ha-dr-design).

5. Topic and channel design

5.1 Naming convention

Pattern: [env].[domain].[event-family].[kind].v[major]

PartValuesExample
envprod, stg, devprod
domainOwning domain from section 2order
event-familyAggregate or entityorder
kindevent, cmd, cdcevent
majorMajor contract version1

Example: prod.order.order.event.v1, prod.stock.reservation.cmd.v1, prod.fulfilment.shipment.event.v2.

Dead-letter topics append .dlq.[consumer-group] to the source topic name, so each consuming group owns its own dead-letter topic, for example prod.order.order.event.v1.dlq.fulfilment. Retry topics follow the same rule with .retry.[consumer-group].

5.2 Topic granularity

OptionWhen to use
One topic per event typeConsumers want only one type; types have different retention or security
One topic per entity with several event typesConsumers need all changes of an entity in order (the default here)
One topic per domainVery small domains; rarely recommended

5.3 Partitioning

TopicPartition keyOrdering guaranteePartitionsReason
prod.order.order.event.v1 (Example)orderIdAll events of one order in order24Peak 6,000 events per second, consumers process 500 per second per partition, so 12 needed, doubled for growth
prod.stock.level.event.v2 (Example)sku + locationIdPer SKU and location48High fan-in from stores
prod.customer.customer.event.v1 (Example)customerIdPer customer12Low volume
[Topic][Key][Guarantee][Count][Reason]

6. Event catalogue

Event IDType (CloudEvents type)TopicOwnerSchema subjectVersionClassificationConsumers
EVT-001 (Example)com.example.order.placed.v1prod.order.order.event.v1@team-orderorder.OrderPlaced1.3.0InternalFulfilment, Notifications, Data platform
EVT-002 (Example)com.example.payment.captured.v1prod.payment.payment.event.v1@team-paymentpayment.PaymentCaptured1.1.0ConfidentialFulfilment, Finance
EVT-003 (Example)com.example.stock.level-changed.v2prod.stock.level.event.v2@team-stockstock.StockLevelChanged2.0.0InternalWeb, Mobile, Marketplaces
[EVT-NNN][type][topic][@team][subject][x.y.z][Class][Consumers]

Each entry links to the producing domain's AsyncAPI 3.1.0 document and its Event API Specification. The catalogue is published in the developer portal next to HTTP APIs.

7. Envelope and schema governance

7.1 Envelope

All events use the CloudEvents 1.0.2 envelope. In the structured mode the attributes travel in the payload; in the binary mode, preferred on the broker, they travel as message headers (prefixed ce_ on Kafka).

AttributeRule in this landscape
specversionAlways 1.0
idUUID generated by the producer; unique per source; used for deduplication
sourceURI of the producing service, for example /order-service/prod
typeReverse-domain name from the catalogue ending in the major contract version, which matches the topic major, for example com.example.order.placed.v1
timeTime of the business fact in UTC, RFC 3339 format
subjectEntity identifier, for example the order ID
datacontenttypeapplication/avro, application/protobuf or application/json
dataschemaURI of the payload schema in the schema registry
Extension: traceparentW3C Trace Context value for end-to-end tracing (CloudEvents distributed tracing extension)
Extension: partitionkeyValue used as the partition key (CloudEvents partitioning extension)

7.2 Serialisation and registry

DecisionChoiceReason
Serialisation format (Example)Avro for internal events, JSON Schema for partner-facing eventsCompact, strong evolution rules; JSON for external readability
Registry (Example)One schema registry per environmentProducers and consumers fetch schemas at runtime
Subject naming (Example)[domain].[EventName]Several event types per topic
Default compatibility (Example)BACKWARD_TRANSITIVENew schema readable by consumers of all previous versions
Override (Example)FULL_TRANSITIVE for events consumed by partnersBoth old and new consumers keep working whatever upgrades first

7.3 Compatibility modes

ModeWhat it guaranteesUpgrade order
BACKWARDConsumers using the new schema can read data written with the previous oneUpgrade consumers first
BACKWARD_TRANSITIVEAs BACKWARD, checked against all earlier versionsUpgrade consumers first
FORWARDConsumers using the previous schema can read data written with the new oneUpgrade producers first
FORWARD_TRANSITIVEAs FORWARD, against all earlier versionsUpgrade producers first
FULL and FULL_TRANSITIVEBoth directions, against the previous or all earlier versionsEither order
NONENo checkNot allowed in production

Mode names are those used by widely deployed schema registries; check the documentation of the registry you run. Breaking changes need a new major version, a new topic (.v2), a period of dual publishing and a deprecation notice following API Deprecation Policy (architecture/api-deprecation-policy).

8. Delivery, ordering and idempotency

ConcernPlatform guaranteeProducer obligationConsumer obligation
DeliveryAt-least-once for all business eventsWait for acknowledgement from all in-sync replicas; enable idempotent producer where supportedCommit offsets only after processing
OrderingPer partition onlyUse the partition key from section 5.3Process one key at a time; do not reorder in thread pools
DuplicatesPossible after retries and rebalancesStable id across retriesIdempotent Receiver: store processed IDs or use upserts by version
Poison messagesDead Letter Channel per consumerValidate against schema before publishingRetry with backoff [3] times, then move to the consumer's .dlq.[consumer-group] topic with error headers
Late or out-of-order eventsNot prevented across partitionsInclude entity version or sequenceIgnore events older than the stored version

9. Publishing from systems of record

TechniqueHow it worksUse whenWatch for
Transactional outbox with polling publisherBusiness change and outbox row written in one transaction; a relay polls the outbox and publishesApplication code can be changed; moderate volumePolling delay, outbox cleanup
Transactional outbox with log tailingAs above, but the relay reads the outbox through CDC on the database logHigher volume, low latencyCDC tooling must be operated
Log-based CDC of business tablesConnector reads the database log and emits change eventsPackaged or legacy application that cannot be changedExposes internal schema; translate to business events before publishing across domains
Native events from the applicationPackaged application publishes its own eventsSaaS or ERP with an event featureVendor schema; map to the catalogue type
Direct publish after commit (dual write)Application commits, then publishesNot allowed for business eventsLost or phantom events on failure
ProducerTechniqueTranslation stepOwner
Order service (Example)Outbox with log tailingNone, outbox holds the integration event@team-order
WMS (Example)Log-based CDCStream processor maps inventory rows to StockLevelChanged@team-stock
ERP (Example)Native business eventsAdapter maps ERP events to catalogue types@team-erp
[Producer][Technique][Translation][@owner]

10. Retention, replay and archive

Topic classRetention on brokerCleanup policyArchiveReplay method
Business events (Example)7 daysDeleteObject storage for 13 months, partitioned by dateReset consumer group offset by time, or reload from archive
Entity state topics (Example)UnlimitedCompact by keyNot neededNew consumers read from the beginning
Commands (Example)3 daysDeleteNoneNot replayed; producers resend
CDC raw (Example)3 daysDeleteNoneRe-snapshot from source
Dead letter (Example)14 daysDeleteTicket attachedReplay tool after fix
[Class][Retention][Policy][Archive][Method]

Replay rules: replays use a dedicated consumer group or a flag in the event headers so that side effects (emails, payments) are not repeated; every replay is logged with requester, range and reason. For personal data, prefer notification events with identifiers, or crypto-shredding (per-subject keys deleted on erasure), and record the approach in the DPIA (compliance/dpia).

11. Security and access control

ControlRule
AuthenticationEach producer and consumer has its own identity (mutual TLS certificate or OAuth 2.0 client credentials), issued by the platform
AuthorisationAccess control lists per topic: write for the owning domain only, read per approved consumer, granted through a request in the catalogue
Encryption in transitTLS on every client and inter-broker connection
Encryption at restBroker storage encrypted with platform-managed or customer-managed keys
Payload protectionField-level encryption or tokenisation for card and special-category fields; keys held outside the broker
Schema registryWrite access for CI pipelines only; humans read
AdminTopic creation only through infrastructure as code with review
AuditAdmin actions, ACL changes and replays logged and retained [13 months]

12. Observability and lineage

SignalMeasureAlert threshold (Example)
Consumer lagMessages or seconds behind the head, per consumer group and partitionAbove 60 seconds for 5 minutes on tier 1 consumers
End-to-end latencyEvent time to consumer completion, 95th percentileAbove 5 seconds for stock events
Dead letter arrivalsCount per consumerAny arrival on tier 1
Producer errorsFailed publishes and retriesAbove 1 % for 5 minutes
Under-replicated partitionsCountAny for more than 5 minutes
Schema rejectionsFailed registrations in CI and at runtimeAny in production
Outbox backlogUnpublished outbox rowsOlder than 2 minutes

Lineage: the catalogue records producer, topic and consumer groups for every event type; trace context in the envelope links spans across hops; the data platform records which datasets are built from which topics.

13. Capacity and service levels

InputValue (Example)
Average event rate, all topics1,500 events per second
Peak event rate6,000 events per second
Average event size including envelope1 KB
Retention for business events7 days
Replication factor3

Example calculation: 1,500 events per second x 1 KB x 86,400 seconds = 129.6 GB per day; x 7 days = 907.2 GB; x 3 replicas = about 2.7 TB of broker storage, plus [30 %] headroom = about 3.5 TB. Peak ingress is 6,000 x 1 KB = 6 MB per second before replication.

TierExample topicsAvailabilityEnd-to-end latency, 95th percentileRecovery pointRecovery time
Tier 1 (Example)Order, payment, stock99.95 %2 secondsMirroring lag below 30 seconds30 minutes
Tier 2 (Example)Customer, notifications99.9 %30 seconds5 minutes4 hours
Tier 3 (Example)Analytics feeds99.5 %15 minutes1 hour24 hours

14. Governance and lifecycle

ActivityEDA leadPlatform teamProducing domainConsuming domainSecurityData governance
Event naming and envelope rulesA, RCCIIC
New event type and schemaCIA, RCCC
Topic provisioning and quotasIA, RRICI
Consumer access requestIRARCC
Breaking change and deprecationCIA, RCII
Retention and privacy rulesCRCICA

Lifecycle: Proposed, Designed (schema and AsyncAPI reviewed), Published (registered in the catalogue), Deprecated (successor published, consumers notified, sunset date set), Retired (topic deleted after archive). A review checklist for every new event type:

  • Named as a past-tense business fact owned by one domain
  • CloudEvents attributes filled as in section 7.1
  • Schema registered with the default compatibility mode or an approved override
  • Partition key chosen and ordering need stated
  • Classification set and personal data fields marked
  • Publishing technique from section 9 named; no dual write
  • AsyncAPI 3.1.0 document committed and linked from the catalogue
  • Consumer dead letter handling and alerts defined

15. Risks and decisions

IDTypeDescriptionResponseOwner
RSK-001 (Example)RiskHot partition on popular SKUs during promotionsComposite key with location; monitor partition skew@team-stock
RSK-002 (Example)RiskConsumers depend on CDC row formatsEVR-001 enforced in review; translation step owned by producer@eda-lead
RSK-003 (Example)RiskFailover loses events within the mirroring lagProducers can replay from the outbox for the last [1 hour]@platform-lead
DEC-001 (Example)DecisionCloudEvents binary mode on the brokerADR-EDA-001@eda-lead
DEC-002 (Example)DecisionBACKWARD_TRANSITIVE as default compatibilityADR-EDA-002@eda-lead
[ID][Type][Description][Response][@owner]

16. Glossary and references

16.1 Glossary

TermMeaning
EventImmutable record of a business fact that already happened
CommandMessage asking one receiver to perform an action
Topic or channelNamed stream on the broker that carries messages
PartitionOrdered subset of a topic; ordering holds only inside it
Consumer groupSet of consumer instances that share the work of reading a topic
Consumer lagDistance between the newest message and the consumer's position
CompactionCleanup that keeps only the latest message per key
OutboxTable written in the business transaction and published by a relay
Crypto-shreddingMaking data unreadable by deleting the key that encrypted it

16.2 References

ReferenceVersion or date checkedUse
AsyncAPI Specification, asyncapi.com3.1.0, released January 2026Channel, operation and message contracts
CloudEvents specification, CNCF, github.com/cloudevents/spec1.0.2Envelope attributes in section 7.1
Enterprise Integration Patterns, Hohpe and Woolf, enterpriseintegrationpatterns.comSite checked YYYY-MM-DDPattern names
Transactional outbox, polling publisher and transaction log tailing, microservices.ioChecked YYYY-MM-DDSection 9
Schema evolution and compatibility, schema registry documentation of your productChecked YYYY-MM-DDSection 7.3 mode names
W3C Trace Context, w3.org/TR/trace-contextLevel 1 Recommendation (Level 2 in progress), checked YYYY-MM-DDtraceparent extension
[Internal standard][Version][Use]

Standard and licence note

Based on public specifications: the AsyncAPI Specification 3.1.0 and the CloudEvents specification 1.0.2, both published under the Apache License 2.0. Pattern names (Publish-Subscribe Channel, Dead Letter Channel, Idempotent Receiver and others) come from Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf and are used by name with attribution; the outbox and log tailing techniques are described in original words with credit to microservices.io. Schema compatibility mode names follow common schema registry usage; product names are trademarks of their owners and this template is not affiliated with or endorsed by any vendor. This template is original text written for this collection. Check the current official version of every specification before use. Template licence: MIT.

संबंधित टेम्पलेट