Set up a Kafka destination¶
SQDR replicates to Apache Kafka through a Stelo Capture Apply extension: the Replicator Service hands each batch of changes to the extension, which sends one message per row change to a Kafka topic with the Kafka Java producer. Nothing is written through ODBC, and SQDR creates no tables or topics.
Supported configurations¶
| Supported | |
|---|---|
| Platforms | Apache Kafka brokers; Azure Event Hubs (its Kafka endpoint); Kafka services that take an API key and secret over SASL PLAIN, such as Confluent Cloud and Oracle Cloud Infrastructure Streaming; Confluent Cloud and Confluent Platform with Schema Registry (Avro); Amazon MSK with SASL/SCRAM or IAM access control. For other platforms or sign-in methods, ask Stelo Support. |
| Connection | The Apply extension runs in Stelo Capture and connects to the brokers itself. There's no ODBC driver: the destination is described on the wizard's Connector step. |
| Replication | Incremental groups and snapshot subscriptions. A snapshot or baseline runs through the source's Capture Agent, so the source needs one (see ODBC and Java connectors). |
| Apply method | Merge only (see Destinations and methods). |
| Message formats | JSON and JSON (classic). See Messages. Avro with Confluent Schema Registry: see Confluent with Schema Registry. |
| Authentication | None; SASL PLAIN (Event Hubs connection string, or an API key and secret); SASL/SCRAM; Amazon MSK IAM. |
| Encryption | TLS (security.protocol=SASL_SSL) with the Event Hubs and API key templates; any Kafka producer security setting through Additional Parameters. |
Firewall rules on the Stelo VM¶
The Stelo VM connects to the brokers: open the brokers' ports outbound (for example 9092, 9093 for Event Hubs, 9096 or 9098 for MSK).
Prepare Kafka¶
Topics¶
- One topic per incremental group. Every member of a group writes to the same topic; each message's
destfield names the destination table. The topic is the Topic parameter (on the Connector step, or in the group's Parameters); without one, it's the group's name with spaces replaced by underscores. A snapshot subscription uses the topic in the destination's parameters, or else the subscription's name. - SQDR doesn't create topics (except the Confluent Avro extension, which creates
one topic per table). Create the topic before the first baseline, with the partitions, replication and retention you
want. If the broker allows automatic topic creation (
auto.create.topics.enable, on by default in Apache Kafka) and the producer may create topics, a missing topic is created with the broker's defaults instead. Verify on the Connector step says whether the topic exists. - Partitions and keys. Messages have no key, so the producer spreads them over the partitions, and Kafka keeps order only within a partition. If your consumers apply the changes in order, use a topic with one partition.
Example, with the Kafka command-line tools:
kafka-topics.sh --bootstrap-server broker1:9092 --command-config admin.properties \
--create --topic SALES_GROUP --partitions 1 --replication-factor 3
Replace broker1:9092 with a broker, admin.properties with your administrator's client settings, and SALES_GROUP
with the group name (or the topic you set).
Permissions¶
On a cluster with ACLs, the principal SQDR signs in as needs:
| Resource | Operations | Why |
|---|---|---|
| The topic | Write, Describe |
To send the messages and read the topic's metadata. Verify also lists the topics to say whether this one exists. |
| The cluster | IdempotentWrite |
The Kafka producer is idempotent by default. |
| The cluster | Describe |
Verify asks the cluster for its brokers. |
| The topic or cluster | Create |
Only if you rely on automatic topic creation. |
kafka-acls.sh --bootstrap-server broker1:9092 --command-config admin.properties --add \
--allow-principal User:sqdruser --operation Write --operation Describe --topic SALES_GROUP
kafka-acls.sh --bootstrap-server broker1:9092 --command-config admin.properties --add \
--allow-principal User:sqdruser --operation IdempotentWrite --operation Describe --cluster
Replace sqdruser with the principal SQDR signs in as.
Managed Kafka services¶
On a managed service, also prepare what it needs: Azure Event Hubs, Confluent Cloud and other API keys, Confluent with Schema Registry, Oracle Cloud Infrastructure Streaming, or Amazon MSK.
Network¶
With TLS, the Stelo Capture Java runtime must trust the brokers' certificates: trust the issuing root CA, in the
truststore named by ssl.truststore.location or in the runtime's default cacerts. Don't trust a server (leaf)
certificate instead: Azure, for example, rotates the Event Hubs leaf certificates and presents different ones behind
its load balancer, while everything it issues under a trusted root CA is accepted.
Create the destination¶
- Name (see Create a destination): choose the DBMS Type Kafka.
- On the Connector step, choose a Template, a Format (see
Messages) and the Destination Schema (the schema part of the messages'
destfield), and fill in the template's fields. The Event Hubs template's Connection string is the shared access policy's. The Event Hubs and API key templates also writesecurity.protocol=SASL_SSL,sasl.mechanism=PLAIN, andsasl.jaas.configwith the sign-in (for Event Hubs, the user name$ConnectionStringand the connection string as password). Producer defaults:batch.size16384,linger.ms5,acksall,compression.typenone. - Enter any other Kafka producer setting (for example a truststore, or the timeouts Microsoft recommends for Event
Hubs) under Additional Parameters. Every parameter except
classNameis passed to the Kafka producer as is. Write Windows paths with forward slashes or double backslashes, for examplessl.truststore.location=C:/certs/truststore.jks. - Click Verify, then save.
The parameters become the destination's Default Parameters. To keep the sign-in out of the parameters, see Keep the sign-in in a secret.
Test the connection. Verify (run by the SQDR Plus Launch Agent) checks the brokers, the sign-in and whether the topic exists, without sending anything. Saving doesn't test a connection.
Keep the sign-in in a secret¶
The Event Hubs connection string and the API secret are written inside sasl.jaas.config, and a
secret reference works only as a whole parameter value. To keep them out of the
parameters, store the whole sasl.jaas.config value as a secret and write
sasl.jaas.config=$$name$$. The groups' copies then hold only the reference: to rotate the key or connection string,
change the secret's value, and every group uses it. Without a secret, change it in the destination and in each group's
Parameters (reload them with Load from Destination).
Group settings for Kafka¶
When you create an incremental group to this destination:
- Topic. The group writes to one topic: the Topic in its Parameters or, without one, the group's name with
spaces replaced by underscores. Create it before the group's first baseline (see Topics). To write
elsewhere, change
topicin the group's Parameters (see Source/Destination). - Parameters. The group copies the destination's parameters when it's created and keeps its own copy: check the topic and the sign-in there. If you changed the destination after creating the group, use Load from Destination.
- DML Replication is always Merge.
- With the JSON format, every member needs a primary key or a unique index (see Limitations).
Check the destination¶
After the incremental group's first baseline (for snapshots, after the first run):
- Group status. On the Groups page, the group shows Actively monitoring and applying change data (see Group status).
-
Messages in the topic. Read the topic, for example:
kafka-console-consumer.sh --bootstrap-server broker1:9092 --consumer.config client.properties \ --topic SALES_GROUP --from-beginningWith the JSON format (see Kafka message formats), each table's baseline is a
SCHEMAmessage, aK, oneLper row and anE. -
Changes. Change a row at the source. After the group's next poll (the Poll Interval; see Scheduling), its
I,UorDmessage arrives in the topic.
Data types¶
A Kafka destination's columns get JSON type names (boolean, integer, number, string, and object and array
for source columns of the same type); see Data type mapping. The message
values follow the column types as described in JSON.
Limitations¶
- A key is needed. With the JSON format, a member needs a primary key or a unique index; otherwise applying its changes fails with "No usable primaryKey or unique index found for table". The destination doesn't check this when you save the subscription. See Keys and indexes.
- Order is kept only within a partition (see Topics).
- Topics aren't created by SQDR.
- Message size. A message larger than the producer's
max.request.size(1 MB by default) or the topic's limit is refused; large LOB columns can reach it. - XML writes nothing (see Messages).
Troubleshooting¶
Problems and messages, with their causes and fixes, are in Troubleshooting › Cloud and streaming destinations.
Related¶
- Kafka message formats
- Managed Kafka services
- Destinations and Destination properties: Default Parameters and Apply extensions
- Microsoft: Apache Kafka client configurations for Event Hubs
- AWS: IAM access control for Amazon MSK and Public access
- Confluent: Confluent Cloud connectors
- Oracle: Streaming with Apache Kafka
- Apache Kafka: Authorization and ACLs