Debezium SQL Server Source
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Preview"
Sends a message for each row inserted, updated or deleted in the tables of a SQL Server database, as it happens (change data capture with Debezium).
Use it to pass the changes of a database on to another system as they happen, for example to keep a search index or a cache up to date, or to copy new orders to a queue, without polling the tables. To read rows with a query again and again, use sqlserver-source.
Output: the body is JSON text in bytes, an object with the column names as keys, such as {"id":1,"name":"Tea","price":4.50}: the row after the change, and for a delete the row before it. The columns are in the order of the table. A DECIMAL column is a JSON number with its decimals, such as 4.50, and a DATE column the number of days since 1970-01-01, such as 20454 for 2026-01-01. The debezium-operation header says what happened: c (insert), u (update), d (delete) or r (a row read by the snapshot, see snapshotMode). debezium-table is the table, as schema.table such as dbo.orders, and debezium-key the primary key of the row as JSON text, such as {"id":1}. Content-Type is application/json.
Good to know: the Kamelet reads the changes that the change data capture (CDC) of SQL Server records, so CDC must be enabled on the database, with EXEC sys.sp_cdc_enable_db, and on each table, such as with EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'orders', @role_name = NULL, which needs a member of sysadmin. SQL Server Agent must run, as its jobs copy the changes into the change tables of CDC. The changes of a table without CDC are not sent. The user needs to read the tables and the change tables, as a member of the db_owner role of the database does. On the first start, the Kamelet by default sends every row of the tables first (snapshotMode). It saves how far it got in the file offsetStorageFileName, or in a Kafka topic, when it stops and once a minute while it runs, and after a restart it goes on from there, so after a crash the changes of the last minute can be sent again. It also keeps the structure of the tables in a schema history: the file schemaHistoryFileName, or a Kafka topic. Keep both files on a disk that outlives the integration, such as a volume in Kubernetes: when the position is lost, everything is sent again as on the first start, and when only the schema history is lost, the Kamelet fails to start with The db history topic is missing, until it is started once with snapshotMode set to recovery. The cleanup job of CDC deletes the changes after 3 days by default, so start a stopped Kamelet again before that. Any other option of the Debezium SQL Server connector can be set for all the Kamelets of the integration as the camel.component.debezium-sqlserver. property of that option, such as camel.component.debezium-sqlserver.columnExcludeList=dbo.customers.ssn.
Configuration Options
The following table summarizes the configuration options available for the debezium-sqlserver-source Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Database Name | Required The name of the database whose changes to send. CDC must be enabled on it. | string | shop | ||
Password | Required The password of the database user | string | |||
Server Name | Required The host name or IP address of the SQL Server server, without the port. | string | db.example.com | ||
Logical Name | Required A name for this source of changes, made of letters, digits, | string | shop | ||
Username | Required The database user to log in as. It needs to read the tables and the change tables of CDC, as a member of the | string | |||
Encrypt Connection | Whether the connection to SQL Server is encrypted with TLS. When true, the certificate of the server must be trusted by Java, or | boolean | true | ||
Position Store | Where the Kamelet saves how far it got. Enum values: * org.apache.kafka.connect.storage.FileOffsetBackingStore * org.apache.kafka.connect.storage.KafkaOffsetBackingStore | string | org.apache.kafka.connect.storage.FileOffsetBackingStore | ||
Kafka Brokers | The Kafka brokers of the Kafka stores of | string | my-cluster-kafka-bootstrap:9092 | ||
Position File | The file where the Kamelet saves how far it got, such as | string | debezium-sqlserver-offsets.dat | /data/offsets.dat | |
Position Topic Partitions | The number of partitions of the topic | integer | 1 | ||
Position Topic Replicas | The number of copies of the topic | integer | 3 | ||
Position Topic | The Kafka topic where the Kafka store saves how far the Kamelet got. It is created when it does not exist. Needed with the Kafka store. | string | shop-offsets | ||
Schema History Store | Where the Kamelet keeps the structure of the tables. Enum values: * io.debezium.storage.file.history.FileSchemaHistory * io.debezium.storage.kafka.history.KafkaSchemaHistory | string | io.debezium.storage.file.history.FileSchemaHistory | ||
Schema History File | The file where the Kamelet keeps the structure of the tables, such as | string | debezium-sqlserver-schema-history.dat | /data/schema-history.dat | |
Schema History Topic | The Kafka topic where the Kafka store keeps the structure of the tables. It is created with one partition when it does not exist. Use a topic of its own, not | string | shop-schema-history | ||
Server Port | The port the SQL Server server listens on. SQL Server uses 1433 unless it was set up otherwise. | integer | 1433 | ||
Snapshot Mode | Whether to send the rows that are already in the tables before the changes. Enum values: * initial * no_data * always * initial_only * when_needed * recovery | string | initial | ||
Tables | The tables whose changes to send, as regular expressions that match | string | dbo.orders,dbo.customers | ||
Trust Server Certificate | Whether to accept the certificate of the server without checking it, as needed for a server with a self-signed certificate. Only for development and tests: the connection can then be intercepted. | boolean | false |
Dependencies
At runtime, the debezium-sqlserver-source Kamelet relies upon the presence of the following dependencies:
-
camel:jackson3
-
camel:kamelet
-
camel:debezium-sqlserver
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:debezium-sqlserver-source"
parameters:
.
.
.
steps:
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml