Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

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:

SourceTopic 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

  1. 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:

    Bash
    kafka-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 artie

    The command creates a SCRAM-SHA-512 credential. For SCRAM-SHA-256, change SCRAM-SHA-512 to SCRAM-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:

    Bash
    kafka-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 prefixed

    Replace the bootstrap server, admin.properties, the password and the user name artie with your own values.

    Artie’s producer writes idempotently. On Kafka versions before 2.8, the user also needs IdempotentWrite on the cluster.

    To let Artie create missing topics, or let your cluster create them automatically, also allow Create:

    Bash
    kafka-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 prefixed
  2. Connect Kafka in the pipeline setup

    When you create a pipeline, the setup reaches Choose your destination after you choose tables.

    1. On Choose your destination, select Kafka, then select Continue.
    2. On Connect Kafka, fill in the fields from the table in this step.
    3. Select Verify destination. Artie shows “Destination verified”.
    4. 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:

    FieldWhat to enter
    Bootstrap serversRequired. A comma-separated host:port list, for example b-1.kafka.example.com:9096,b-2.kafka.example.com:9096.
    Topic prefixRequired. The start of every topic name. Letters, digits, ., _, and - only.
    AuthenticationSCRAM-SHA-512, SCRAM-SHA-256, PLAIN, AWS MSK IAM, or None.
    Username and PasswordRequired for SCRAM and PLAIN.
    AWS role ARNRequired 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 TLSOn 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 topicsOff 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:

    Text
    broker <id> at <host>:<port> is unreachable

    Check 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.

  3. 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:

JSON
{"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:

JSON
{
  "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:

  • op is c for inserts, u for updates, d for deletes, and r for rows from a backfill.
  • For a delete, after is null and before holds the deleted row.
  • source.ts_ms is when the change happened in the source, in milliseconds since the Unix epoch.
  • For a backfill row, source.ts_ms is when Artie read the row.
  • Values use Debezium’s encodings, which the schema describes 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:

LimitationDetail
Writer settings don’t applyThe 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 destinationDeploy fails while a table has history mode, column hashing or column encryption on. Turn them off for each table.
Settings that still applyAuto-replicate new tables and Disable alert emails.
Shared source readersNot supported. The source reader must be dedicated to the pipeline.
SourcesS3 sources aren’t supported. Oracle sources need a setting that only Artie can turn on.
Table-level monitorsSaving one fails with Table monitors aren't supported for Kafka destinations. Monitor the whole pipeline instead.
Emptying topics before a backfillTopics can’t be emptied, dropped, or swapped. See Backfills.
Messages over 1 MiBSkipped. See Message size.
Schema change messagesNot published. Artie publishes row changes only. A column’s type and presence show up in each message’s schema.
SSH tunnels and PrivateLinkNot 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?