Home/Learn/Apache Kafka/Debezium CDC Connector

Debezium CDC Connector

Advanced
Kafka Connect

Debezium is a log-based CDC connector that streams database row-level changes into Kafka topics with sub-second latency and zero impact on the source database.

Overview

Debezium reads the database's binary log (MySQL binlog, PostgreSQL WAL) directly, capturing every INSERT, UPDATE, and DELETE as a Kafka event with before and after row images.

MySQL Debezium Connector Setup

Register the connector via Kafka Connect REST API. Creates one Kafka topic per table in {server}.{database}.{table} format.

Debezium — MySQL CDC connector
curl -X POST http://kafka-connect:8083/connectors \
  -H "Content-Type: application/json" \
  -d '{
    "name": "mysql-orders-connector",
    "config": {
      "connector.class": "io.debezium.connector.mysql.MySqlConnector",
      "database.hostname": "mysql",
      "database.port": "3306",
      "database.user": "debezium",
      "database.password": "secret",
      "database.server.id": "1",
      "topic.prefix": "myapp",
      "database.include.list": "orders_db",
      "table.include.list": "orders_db.orders",
      "transforms": "unwrap",
      "transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState"
    }
  }'
# Events: op=c (insert), op=u (update), op=d (delete)

Key Points to Remember

  • 1Debezium reads DB transaction logs — zero polling overhead on the source DB
  • 2Every INSERT/UPDATE/DELETE becomes a Kafka event with before/after row image
  • 3op field: c=create, u=update, d=delete, r=snapshot read
  • 4ExtractNewRecordState SMT flattens the envelope to just the after image
  • 5Requires binlog_format=ROW for MySQL; wal_level=logical for PostgreSQL

Interview Questions

Sign in to ask Aria
1

What is CDC and how does Debezium implement it?

MediumConfluent
2

What is the difference between log-based CDC and polling-based CDC?

MediumAmazon
3

What does the ExtractNewRecordState (unwrap) SMT do in Debezium?

MediumLinkedIn
4

How would you use Debezium to implement the Outbox Pattern?

HardNetflix
5

What are the database prerequisites for running Debezium against MySQL?

MediumFlipkart

Ask Aria about Debezium CDC Connector

Your personal AI tutor — ask anything about this concept

Revision Status

Personal Notes

Sign in to save personal notes for this topic.

Discussion

Sign in to join the discussion.

Loading discussion…