Skip to content
Weik.ioDocs
2026.2
Try Weik.io

Change tracking

Weik.io 2026.2

A change tracking integration publishes a database's changes into a channel with Debezium. Product page · Video

Watch: React to database changes, 3:47

The video publishes database changes into a channel with change tracking.

On this page

When other integrations need to react to a database’s changes, a change tracking integration publishes them as events. It runs Debezium with any of its connectors, which follow the database’s change log and publish each insert, update and delete into a channel. You write a document for it and no route.

Write the change tracking document#

shop/events/order-changes.yaml
apiVersion: weik.io/v1
kind: change-tracking
metadata: { name: order-changes, project: shop }
spec:
  type: postgres
  databaseHostname: "{{orders-db-host}}"
  databasePort: 5432
  databaseDbname: orders
  databaseUser: weikio_cdc
  databasePassword: "{{orders-db-password}}"
  offsetTable: weikio_offsets
  channel: order-changed
  parameters:
    tableIncludeList: public.orders
    additionalProperties.offset.storage.jdbc.connection.url: "jdbc:postgresql://{{orders-db-host}}:5432/orders"
    additionalProperties.offset.storage.jdbc.connection.user: weikio_cdc
    additionalProperties.offset.storage.jdbc.connection.password: "{{orders-db-password}}"
Field What it is
type postgres, mysql, sqlserver, oracle, mongodb, db2 or another Debezium connector on the classpath
database* The connection settings, under the connector’s option names. Each is a value or a placeholder for a variable or secret. Leave out the ones your connector doesn’t use.
parameters Any other connector option, handed to Debezium as written, such as tableIncludeList or snapshotMode
offsetTable The table where the connector keeps its position, a bare table name
channel The channel the changes go into, declared in the project as any other channel

The connector keeps its position in a table of a database you name, usually the tracked database, so the three additionalProperties.offset.storage.jdbc.connection parameters are required. The sqlserver, mysql, oracle and db2 connectors also keep a schema history beside the offsets in the same database. Keep both tables out of what the connector tracks.

weikio init order-changes --kind change-tracking --project shop writes a change tracking integration that publishes into order-changes-changes. It also prints the weikio init line that creates that channel.

Prepare the database#

Debezium follows the database’s change log, so set the database up for it before the first start. For PostgreSQL with a login that isn’t a superuser, check that:

  • The server runs with wal_level=logical.
  • The login has LOGIN REPLICATION.
  • The login has SELECT on each tracked table.
  • The login has CREATE on the schema of the offset table.
  • A publication of the tracked tables exists with the name dbz_publication, Debezium’s default.
  • pg_hba.conf has a host replication line that lets the login connect from the agent’s host.
  • Each tracked table has REPLICA IDENTITY FULL.

With REPLICA IDENTITY FULL, before has the whole old row in an update or a delete.

SQL Server needs SQL Server Agent running and change data capture turned on for the database and each table. MySQL needs a binary log in ROW format. Debezium’s documentation of each connector has the details.

Camel doesn’t bundle MySQL’s JDBC driver, which is GPL-licensed. List it in the dependencies of a MySQL change tracking integration, such as mvn:com.mysql:mysql-connector-j:9.6.0.

Deploy it#

Terminal
$ weikio apply -f ./shop/events/
$ weikio deploy shop/order-changes --env production

A change tracking integration runs one copy at a time, so two agents never run two connectors against one offset table. The running copy stops while its agent can’t reach the hub.

What lands in the channel#

Each change is one event whose body is Debezium’s envelope:

{
  "op": "u",
  "ts_ms": 1760000000000,
  "before": { "id": 1042, "status": "open" },
  "after": { "id": 1042, "status": "paid" },
  "source": { "connector": "postgresql", "table": "orders", "lsn": 24023128 }
}

The connector stores its position about once a minute, so a restart can replay up to a minute of changes.

Each event’s ID is made from the change’s table and key and from its position in the database. A change that Debezium sends again soon after a restart gets the same ID and is stored once. A replay after a longer outage is stored again, so the readers of the channel should handle a duplicate, for example with #weikioIdempotent.

Starting over#

The connector keeps its position under the integration’s name, so a new name starts from a fresh snapshot. A database restored from a backup reuses its old positions in the change log, so after a restore, start the tracking under a new name.

Sign in to the live demo

Sign in with the shared viewer account. It can open every screen of the example projects but can't change anything.

E-mail
viewer@demo.weik.io
Password
try-weikio-live-demo
Open the live demo