Destinations
Kafka destination connector: setup and configuration
Publish change events to your own Apache Kafka or Amazon MSK cluster, one topic per table as Debezium JSON, with SASL, MSK IAM, TLS or mutual TLS.
Prerequisites
- Kafka destinations turned on for your account. Contact Artie to enable them.
- An Apache Kafka or Amazon MSK cluster.
- Network access from Artie’s IP addresses to every broker the cluster advertises, including brokers outside your bootstrap list.
- A Kafka principal that can write to Artie’s topics. You create it in Give Artie access to the cluster.
- A source with a dedicated source reader. Kafka destinations can’t use a shared source reader.
- On a cluster that doesn’t create topics automatically: a topic for each table, or Create missing topics turned on.
Artie connects to the brokers directly. Kafka destinations don’t support SSH tunnels or PrivateLink.
Create missing topics needs Kafka 2.4 or later and permission to create topics.
How Artie writes to Kafka
Artie’s reader publishes each change straight to your cluster. No separate writer runs between your source and your topics, so the settings Artie’s writer applies to other destinations don’t apply. See Limitations.
Each table gets its own topic, named <topic prefix>.<table identifier>. The table identifier depends on the source. This table shows it for four sources:
| Source | Topic name |
|---|---|
| PostgreSQL | <prefix>.<schema>.<table>. Partitions publish to their parent table’s topic. |
| MySQL | <prefix>.<database>.<table> |
| Microsoft SQL Server | <prefix>.<database>.<schema>.<table> |
| MongoDB | <prefix>.<database>.<collection>. In the collection name, Artie drops double quotes and replaces each other character that isn’t a letter, digit, ., _ or - with __. |
Tables that unify across schemas publish to <prefix>._.<table>. SQL Server tables that unify across databases publish to <prefix>.<schema>.<table>.
Set up Kafka as a destination
Give Artie access to the cluster
Artie writes to topics that start with your topic prefix. The examples use the prefix
artie. Replace it with your own.Create a user for Artie. On Amazon MSK, skip the command below: create the user as an AWS Secrets Manager secret whose name starts with
AmazonMSK_, encrypt it with a customer managed KMS key, and associate the secret with the cluster. Amazon MSK supports only SCRAM-SHA-512, so choose SCRAM-SHA-512 in Artie.On other clusters, run this command with an admin client configuration:
Bashkafka-configs.sh --bootstrap-server b-1.kafka.example.com:9096 --command-config admin.properties \ --alter --add-config 'SCRAM-SHA-512=[password=s3cure-Passw0rd]' \ --entity-type users --entity-name artieThe command creates a SCRAM-SHA-512 credential. For SCRAM-SHA-256, change
SCRAM-SHA-512toSCRAM-SHA-256. PLAIN users are set in the brokers’ JAAS configuration instead.Then allow the user to describe and write to topics with your prefix:
Bashkafka-acls.sh --bootstrap-server b-1.kafka.example.com:9096 --command-config admin.properties \ --add --allow-principal User:artie \ --operation Describe --operation Write \ --topic artie --resource-pattern-type prefixedReplace the bootstrap server,
admin.properties, the password and the user nameartiewith your own values.Artie’s producer writes idempotently. On Kafka versions before 2.8, the user also needs
IdempotentWriteon the cluster.To let Artie create missing topics, or let your cluster create them automatically, also allow
Create:Bashkafka-acls.sh --bootstrap-server b-1.kafka.example.com:9096 --command-config admin.properties \ --add --allow-principal User:artie \ --operation Create \ --topic artie --resource-pattern-type prefixedCreate an IAM role in the AWS account that owns the cluster. Artie assumes this role to sign in. Attach a policy that lets the role connect to the cluster and write to topics with your prefix:
JSON{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kafka-cluster:Connect", "kafka-cluster:WriteDataIdempotently" ], "Resource": "arn:aws:kafka:us-east-1:123456789012:cluster/orders-cluster/*" }, { "Effect": "Allow", "Action": [ "kafka-cluster:DescribeTopic", "kafka-cluster:WriteData" ], "Resource": "arn:aws:kafka:us-east-1:123456789012:topic/orders-cluster/*/artie.*" } ] }Replace the Region
us-east-1, the account ID123456789012and the cluster nameorders-clusterwith your own.To let Artie create missing topics, or let your cluster create them automatically, add
kafka-cluster:CreateTopicto the topic statement.The role’s trust policy must allow Artie’s AWS principal,
arn:aws:iam::788826912768:user/ci, to assume it. If you also set an External ID, add ansts:ExternalIdcondition with the same value. On a data plane you run yourself, trust the IAM identity your data plane runs as.Connect Kafka in the pipeline setup
When you create a pipeline, the setup reaches Choose your destination after you choose tables.
- On Choose your destination, select Kafka, then select Continue.
- On Connect Kafka, fill in the fields from the table in this step.
- Select Verify destination. Artie shows “Destination verified”.
- Select Continue.
Kafka doesn’t appear on Choose your destination when Kafka destinations are off for your account or the source uses a shared source reader. The setup has no Network access or Prepare destination step for Kafka.
The Connect Kafka step has these fields:
Field What to enter Bootstrap servers Required. A comma-separated host:portlist, for exampleb-1.kafka.example.com:9096,b-2.kafka.example.com:9096.Topic prefix Required. The start of every topic name. Letters, digits, .,_, and-only.Authentication SCRAM-SHA-512, SCRAM-SHA-256, PLAIN, AWS MSK IAM, or None. Username and Password Required for SCRAM and PLAIN. AWS role ARN Required for AWS MSK IAM. The role from Give Artie access to the cluster. External ID (optional) For AWS MSK IAM, if the role’s trust policy requires one. Use TLS On by default. Turn it off only for brokers with a plaintext listener. Hidden with AWS MSK IAM, which always uses TLS. CA certificate (optional) A PEM bundle Artie uses instead of the system roots to verify the brokers. Hidden while Use TLS is off. Client certificate (optional) and Client key (optional) A PEM pair for mutual TLS. A client certificate needs its key. Hidden while Use TLS is off. Create missing topics Off by default. Turn it on if your cluster doesn’t create topics automatically. See Topic creation. When Artie verifies the destination, it signs in to a bootstrap server. It then checks that it can reach every broker the cluster advertises. Producers write to each partition’s leader, so an unreachable broker would fail writes after you deploy. If a broker isn’t reachable, the error starts like this:
Textbroker <id> at <host>:<port> is unreachableCheck your firewall rules and the brokers’ advertised listeners.
To change these fields on an existing pipeline, select Edit pipeline, then open the Destination: Kafka tab.
Deploy the pipeline
On Review and deploy, select Validate and deploy. Artie publishes each table’s existing rows to its topic as backfill messages, and publishes changes as they happen.
Advanced
These sections describe the messages Artie publishes and how it handles topics, failed publishes, large messages, backfills and billing.
Message format
Each message is one change to one row, as Debezium-style JSON.
The key holds the row’s primary key, so every change to a row goes to the same partition, in order:
{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"default":null,"field":"id","name":"","parameters":null}],"optional":false,"field":""},"payload":{"id":1042}}The value has a schema that describes each column’s type, and a payload with the change. This example shows the payload:
{
"payload": {
"before": null,
"after": {"id": 1042, "status": "pending"},
"source": {"connector": "reader", "ts_ms": 1792537200000, "db": "shop", "schema": "public", "table": "orders"},
"op": "c"
}
}Read the payload fields like this:
opiscfor inserts,ufor updates,dfor deletes, andrfor rows from a backfill.- For a delete,
afterisnullandbeforeholds the deleted row. source.ts_msis when the change happened in the source, in milliseconds since the Unix epoch.- For a backfill row,
source.ts_msis when Artie read the row. - Values use Debezium’s encodings, which the
schemadescribes for each column.
Artie compresses batches with LZ4. Kafka clients decompress them automatically.
Topic creation
Kafka creates topics automatically when auto.create.topics.enable is on. It’s on by default in Apache Kafka and off by default on Amazon MSK. On a cluster that enforces ACLs or IAM, automatic creation also needs Artie’s principal to have permission to create topics (Create, or kafka-cluster:CreateTopic on MSK IAM).
If it’s off, a write to a topic that doesn’t exist fails. Without Create missing topics, Artie keeps retrying and the pipeline reports an error until the topic exists. Create topics before you add tables to the pipeline, including tables Artie adds automatically.
With Create missing topics on, Artie creates a topic when a write fails because the topic doesn’t exist, then retries the write. The new topic uses your cluster’s default partitions, replication factor, and retention. Artie never changes topics that already exist. To use other settings, create the topic yourself before the pipeline writes to it.
Creating a topic needs permission to create topics and Kafka 2.4 or later. If the broker refuses, for example because the permission is missing, the pipeline reports the broker’s error. That error starts with failed to create topic.
Delivery guarantees and retries
Delivery is at least once. Make your consumers idempotent, for example by upserting on the message key.
Artie waits for every in-sync replica to acknowledge a message before it counts the message as published.
If a publish fails, Artie sends the failed messages again, up to 10 attempts in total. It waits up to 5 seconds between attempts. Artie doesn’t resend messages that Kafka already accepted.
If every attempt fails, the pipeline reports an error. Artie only advances its position in your source after Kafka accepts the messages, so a failed publish doesn’t lose changes.
After an error or a restart, Artie publishes again from its last committed position, so consumers can see some messages twice.
Message size
Artie sends messages up to 1 MiB, counting the key, value and headers. Artie skips a larger message and keeps going. It sends a row skipped webhook event with the table and primary key.
Make sure your topics accept messages of at least 1 MiB. The limit is the topic’s max.message.bytes or the broker’s message.max.bytes.
Setting the pipeline’s message compression to GZIP means fewer rows are skipped. Artie then gzips values of 500 KiB or more before it checks their size. It keeps the gzipped value only when that makes the message smaller.
Gzipped messages carry the header artie-compression: gzip. Consumers must check for that header and decompress the value before parsing it.
Backfills
Kafka topics can’t be emptied before a backfill. When you backfill or restart a backfill, Artie publishes every row again with op set to r. The new messages land after the messages already in the topic.
The backfill dialog says “Kafka topics are kept as they are. The backfill is published on top of the existing messages.” Consumers see each backfilled row again, so handle r like an upsert.
Monitoring and billing
Artie counts the rows it publishes. Pipeline monitors and charts for a Kafka destination use those counts and the time from a change in your source to its publish.
Billing counts published inserts, updates, and deletes. Rows from backfills (op r) aren’t billed.
Limitations
Kafka destinations differ from other destinations in these ways:
| Limitation | Detail |
|---|---|
| Writer settings don’t apply | The Dashboard hides history mode, column hashing, column encryption, Soft-delete rows, Drop deleted columns, Cast all columns to string and flush rules. It hides Skip deletes unless a table already has it on. It also hides the Additional data, Data handling and Optimizations settings. |
| Table settings chosen before the destination | Deploy fails while a table has history mode, column hashing or column encryption on. Turn them off for each table. |
| Settings that still apply | Auto-replicate new tables and Disable alert emails. |
| Shared source readers | Not supported. The source reader must be dedicated to the pipeline. |
| Sources | S3 sources aren’t supported. Oracle sources need a setting that only Artie can turn on. |
| Table-level monitors | Saving one fails with Table monitors aren't supported for Kafka destinations. Monitor the whole pipeline instead. |
| Emptying topics before a backfill | Topics can’t be emptied, dropped, or swapped. See Backfills. |
| Messages over 1 MiB | Skipped. See Message size. |
| Schema change messages | Not published. Artie publishes row changes only. A column’s type and presence show up in each message’s schema. |
| SSH tunnels and PrivateLink | Not supported. Saving a Kafka connector with PrivateLink fails with PrivateLink isn't supported for Kafka. |
Frequently asked questions
These answers cover duplicate messages, missing topics and deletes.
Why do my consumers see the same message twice?
A publish was retried, the pipeline restarted, or a table was backfilled again. Delivery is at least once, so make consumers idempotent. See Delivery guarantees and retries.
Why is the pipeline failing with an unknown topic error?
The topic doesn’t exist and your cluster doesn’t create topics automatically. Create the topic, or turn on Create missing topics. See Topic creation.
How do I tell a delete from an update?
Read op in the message value. It’s d for deletes, where before holds the deleted row, and u for updates.
Was this page helpful?
- Need help? Message us on Slack or email [email protected].
- Want a walkthrough? Book a demo.
- LLM? Read llms.txt.