First connector
Prepare the database first (database setup), then register a connector with the Kafka Connect REST API:
{
"name": "orders-cdc",
"config": {
"connector.class": "sh.oso.connect.oracle.OracleCdcSourceConnector",
"tasks.max": "1",
"cdc.database.host": "db.example.internal",
"cdc.database.port": "1521",
"cdc.database.service": "ORCLCDB",
"cdc.database.user": "c##cdc",
"cdc.database.password": "${file:/opt/kafka/secrets/oracle.properties:password}",
"cdc.database.pdbs": "ORCLPDB1",
"cdc.tables.include": "ORCLPDB1\\.APP\\.ORDER.*",
"cdc.tables.exclude": "ORCLPDB1\\.APP\\.ORDER_AUDIT",
"cdc.topic.prefix": "app",
"cdc.kafka.bootstrap.servers": "kafka:9092"
}
}
curl -s -X POST -H 'Content-Type: application/json' --data @orders-cdc.json http://localhost:8083/connectors
curl -s http://localhost:8083/connectors/orders-cdc/status
Points worth knowing before the first run:
- Where to connect. In a container database the mining user connects to the root container
(the
CDB$ROOTservice,ORCLCDBhere), not to a PDB. The PDBs to capture are listed incdc.database.pdbs; table patterns are regular expressions matched againstPDB.SCHEMA.TABLE. For a non-container database leavecdc.database.pdbsempty and matchSCHEMA.TABLE. - Check first. Run
oracle-cdc-doctor check --config orders-cdc.json. It reports what is missing with the SQL to fix it. Kafka Connect runs the doctor's fast rules when the connector is created or updated, and refuses the configuration on a blocking finding (see oracle-cdc-doctor). - Credentials. Passwords are Connect
PASSWORDtypes and never appear in logs. Use a config provider as shown rather than a literal. - Broker access.
cdc.kafka.bootstrap.serverslets the connector create its internal topics, journal long transactions, keep schema versions across restarts and read signals. Without it the connector still captures, but those features are off. Security settings for these clients go undercdc.kafka.*. - One task. The engine pipelines mining and decoding internally; a
tasks.maxabove one is accepted with a warning and ignored. - Converters. Records are serialised by the worker's converters, or by
key.converterandvalue.converterset on the connector. JSON works as it is. For Avro, set bothcdc.schema.name.adjustment.modeandcdc.field.name.adjustment.modetoavrobefore the first record, because Oracle names such asORDER#are not valid Avro names; with the converter set on the connector, validation refuses column names Avro does not allow. With broker access and a converter other than JSON, setcdc.journal.converterto match. See using an Avro converter. - Columns to keep out of Kafka.
cdc.columns.excludedrops named columns before their values are read into the connector (see excluded columns). Set it before the first start: a snapshot or a change published without it cannot be withdrawn.
What happens at the first start
- The connector records the database's current SCN and identity as its start position and writes
a heartbeat record to
app.cdc.heartbeat(the prefix followed by.cdc.heartbeat). The heartbeat's offset makes the start position durable before the first change. A transaction already open at that moment is captured whole when it commits: the connector reads the redo from that transaction's start, so the redo since the start of the oldest open transaction must still be on disk. The worker log names that transaction. - With the default
cdc.snapshot.mode=initial, it reads the rows the captured tables already hold and publishes them asop=rrecords, while it streams the changes made meanwhile (see snapshots). Setcdc.snapshot.mode=noneto stream only. - Changes then flow to one topic per table,
app.ORCLPDB1.APP.ORDERSfor example, in the Debezium-compatible format. - On a quiet database a heartbeat every ten seconds (
cdc.heartbeat.interval.ms) moves the committed offset forward without writing to the source database. - A
startupevent onapp.cdc.opsrecords the start position; if the task ever stops, astopevent names the error code and its runbook.
The full property list is generated from the code into the configuration reference.