Order 1001 is marked as shipped in MySQL, but Kafka still contains its earlier state. Both records can be valid. To see which state a consumer would apply, inspect the key, partition, offset, change-type header, and business fields together.
Apache SeaTunnel 3.0.0 reads the initial MySQL snapshot and subsequent binlog events. A metadata transform exposes the source database, table, and row kind. A SQL transform shapes the order record, and the Kafka sink writes JSON with those three metadata fields in the headers.
I ran the lab.orders → orders-cdc job on a local single-node Zeta 3.0.0 cluster (JDK 11, MySQL 8.4.11, Kafka 4.2.0). The test used checksum-verified Apache Maven release JARs. The container commands below are an alternative; I did not run them for this configuration. The official Docker recipe uses a different table and topic.
Prepare a disposable source and an empty topic
Start with a development MySQL instance and a Kafka broker reachable as mysql and kafka from a shared seatunnel-network Docker network. Configure MySQL row-based binlogging with full row images and set up the CDC account with the permissions required by the MySQL CDC connector. Pre-create an empty Kafka topic named orders-cdc with three partitions. Keep the partition count unchanged during the check. Verify the SeaTunnel image contains the matching connectors and that the MySQL JDBC driver is in the source plugin’s library directory. The official test had that driver in place; the recipe does not guarantee a particular image already includes it.
Pull the pinned image for the optional container path:
docker pull apache/seatunnel:3.0.0 Use an isolated database and run the seed SQL once:
CREATE DATABASE lab; CREATE TABLE lab.orders ( id BIGINT NOT NULL PRIMARY KEY, order_no VARCHAR(64) NOT NULL, user_id BIGINT NOT NULL, status INT NOT NULL, amount DECIMAL(10, 2) NOT NULL ); INSERT INTO lab.orders (id, order_no, user_id, status, amount) VALUES (1001, 'ORD-1001', 501, 0, 19.99), (1002, 'ORD-1002', 502, 1, 29.99); Write the Kafka key and headers deliberately
Save this as jobs/mysql-orders-to-kafka.conf. Supply your lab account password locally, and choose a MySQL CDC server ID that does not collide with another replication client. Do not commit secrets.
env { parallelism = 1 job.mode = "STREAMING" } source { MySQL-CDC { plugin_output = "mysql_orders_raw" url = "jdbc:mysql://mysql:3306/lab" username = "cdc" password = "REPLACE_WITH_LAB_PASSWORD" server-id = "61719" table-names = ["lab.orders"] startup.mode = "initial" schema-changes.enabled = false } } transform { Metadata { plugin_input = "mysql_orders_raw" plugin_output = "mysql_orders_with_meta" metadata_fields { Database = source_database Table = source_table RowKind = change_type } } Sql { plugin_input = "mysql_orders_with_meta" plugin_output = "kafka_orders" query = "select id as order_id, order_no, user_id, amount, case when status = 0 then 'CREATED' when status = 1 then 'PAID' when status = 2 then 'SHIPPED' else 'OTHER' end as status_name, source_database, source_table, change_type, CONCAT(source_database, '.', source_table) as source_name, 'mysql_cdc' as sync_source from dual where id is not null" } } sink { Kafka { plugin_input = "kafka_orders" bootstrap.servers = "kafka:9092" topic = "orders-cdc" format = json partition_key_fields = ["order_id"] kafka_headers_fields = ["source_database", "source_table", "change_type"] } } The partition key uses the renamed business field, order_id. Configure the metadata fields as Kafka headers because downstream consumers need provenance and change type separately from business data. In the local capture, all five records shown below carried those fields in the headers and omitted them from the JSON value.
With the services ready, launch the pinned image from the directory that contains jobs. Follow the versioned Docker guide if you use a different image layout.
docker run --rm -it \ --name seatunnel-orders \ --network seatunnel-network \ --memory 3g \ -v "$PWD/jobs:/config:ro" \ apache/seatunnel:3.0.0 \ ./bin/seatunnel.sh -DJvmOption="-Xms512m -Xmx2g" \ -m local -c /config/mysql-orders-to-kafka.conf Compare one order across two phases
Read the topic before changing MySQL. If you use kcat, set KAFKA_BROKER to an address the client can reach, including the addresses returned in broker metadata.
kcat -C -b "$KAFKA_BROKER" -t orders-cdc -o beginning \ -f 'partition=%p offset=%o key=%k headers=%h value=%s\n' Wait for the initial records for orders 1001 and 1002. Then commit the update and insert individually, or run them with autocommit enabled:
UPDATE lab.orders SET status = 2, amount = 39.99 WHERE id = 1001; INSERT INTO lab.orders (id, order_no, user_id, status, amount) VALUES (1003, 'ORD-1003', 503, 0, 59.99); Check these records, independent of how many messages the topic contains:
| Check | What to look for |
|---|---|
| Snapshot | Records for 1001 and 1002. For 1001, confirm source_database=lab, source_table=orders, and change_type=+I in the headers. Check that those fields are absent from the JSON value. |
| Update | Order 1001 has a +U record with status_name=SHIPPED and an amount of 39.99. Compare its key and partition to the earlier snapshot record. In the same partition, the update should have a higher offset. |
| Insert | Order 1003 has a +I record with status_name=CREATED. Check its order number and amount as well. |
What came out of Kafka
| Order | Change type | Partition | Offset | Status | Amount |
|---|---|---|---|---|---|
| 1001 | +I | 0 | 0 | CREATED | 19.99 |
| 1002 | +I | 0 | 1 | PAID | 29.99 |
| 1001 | -U | 0 | 2 | CREATED | 19.99 |
| 1001 | +U | 0 | 3 | SHIPPED | 39.99 |
| 1003 | +I | 1 | 0 | CREATED | 59.99 |
One committed SQL update produced two records: -U carried the previous state and +U carried the new state. Both used the key {"order_id":1001}. A consumer that builds the current order state should apply the +U record as the new state, not count the two records as two business updates. The offsets above are from this run, not values to hard-code.
A snapshot row and a newly inserted row can both carry +I. Don’t treat that header alone as a business event meaning “a customer just placed an order.” Likewise, offsets are comparable within one partition, not across a topic. If any expected record fails to appear by your test deadline, keep the consumer output and job logs and mark the check unresolved.
Before handing the topic to another team, document which fields identify an order, which records the consumer applies, and what the test did not cover. A green job status and a stable key do not establish end-to-end exactly-once delivery. This run did not cover replay, deletes, primary-key changes, or downstream state reconstruction. Test those with the consumer you intend to run.
