PrepZone Logo
PrepZone

Debezium CDC from VaultCommerce Postgres

Capture Postgres WAL changes and stream them to Kafka — the bridge between OLTP and search indexes.

Why this matters

  • VaultCommerce search index updates from vaultcommerce.cdc.postgres.products — no dual-write from order API.
  • CDC captures INSERT/UPDATE/DELETE with before/after payloads.
  • Postgres logical replication slot prevents WAL bloat if consumer stalls.
  • Foundation for event-driven microservices without polling.
Postgres WALVaultCommerce OLTP
CDC topic
Search indexer
Debezium reads Postgres WAL and publishes row-level change events to Kafka topics.

Postgres connector setup

Debezium creates publication and replication slot on vaultcommerce database. plugin.name=pgoutput. Events land on vaultcommerce.cdc.postgres.public.products with envelope containing op, before, after. VaultCommerce Elasticsearch sink consumes CDC topic.

Key points

  • CDC (change data capture) — streaming DB mutations from WAL
  • Replication slot — Postgres holds WAL until Debezium acknowledges
  • Debezium envelope — op code (c/u/d/r), source metadata, payload
  • Snapshot mode — initial bulk read (initial, never, when_needed)
  • Outbox pattern — alternative when CDC of application table is insufficient

Operational concerns

Monitor replication slot lag — stalled connector fills Postgres disk. Schema changes need include.schema.changes handling. Tombstone events on DELETE for compacted downstream stores.

VaultCommerce rollout checklist

Before promoting changes that touch the VaultCommerce order and payment event backbone, run the staging KRaft cluster (Kafka 3.7+, Schema Registry 7.x) through a 10k events/min soak test. Compare producer request latency p99 and consumer lag per group against the pre-deploy baseline. Debezium streams WAL changes to Kafka. Document the change in the internal topic registry, attach Grafana screenshots to the change ticket, and keep an engineer on lag dashboards for 30 minutes after production rollout — roll back the service release before altering broker-level settings if lag or under-replicated partitions spike.

Java
{
  "name": "vaultcommerce-postgres-cdc",
  "config": {
    "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
    "database.hostname": "postgres-primary.vaultcommerce.internal",
    "database.port": "5432",
    "database.user": "debezium",
    "database.password": "${DEBEZIUM_PASSWORD}",
    "database.dbname": "vaultcommerce",
    "topic.prefix": "vaultcommerce.cdc.postgres",
    "table.include.list": "public.products,public.inventory",
    "plugin.name": "pgoutput",
    "slot.name": "vaultcommerce_debezium",
    "publication.autocreate.mode": "filtered"
  }
}

Quick recall

Everything you need if you only revisit this box.

  1. Debezium streams WAL changes to Kafka.
  2. Monitor replication slot lag on Postgres.
  3. Avoid dual-write — let CDC propagate truth.

Test yourself

Answer these before moving on — recall is what makes it stick.