← Back to microservices patterns map
👂
Microservices Pattern

Change Data Capture (CDC)

Capture database changes and publish them as events.

CDC

Detailed Description

CDC watches the database transaction log rather than relying on application code to publish events.

It is commonly used for outbox publishing, projections, search indexes, and analytics streams.

Visual Diagram

CDC via DB Transaction Log
  Application → writes to [PostgreSQL]
  PostgreSQL  → WAL (Write-Ahead Log)
  [Debezium]  → reads WAL changes
               → publishes to Kafka:
                  orders.created   { ... }
                  orders.updated   { ... }
  Consumers   → react to DB changes

Tradeoffs

Pros

Low app-code change, reliable change stream

Cons

Operational complexity and schema evolution

Examples: Debezium, Kafka Connect, database logs