Published Dec 1, 2026 ⦁ 10 min read
TDengine Kafka Connector: Source Code and Setup

TDengine Kafka Connector: Source Code and Setup

Set up the TDengine Kafka Connector by pinning a release, building its full package, and testing that exact package in Kafka Connect. Release v1.1.6 is a starting point - not proof that it works with every Java, Kafka, or TDengine version.

The connector supports 2 data directions: source reads TDengine data into Kafka; sink writes Kafka records into TDengine. Each needs its own verified class and settings.

This guide covers how to:

  • Check source code, dependencies, and version requirements.
  • Build with Maven and install the full plugin package on every worker.
  • Confirm plugin discovery, configure the connector, and protect credentials.
  • Test records, offsets, restart recovery, task distribution, and resource use.

A successful build or a RUNNING task is not enough. Deployment approval should rest on record delivery and failure-recovery tests.

TDengine Kafka Connector: Build-to-Deployment Workflow

TDengine Kafka Connector: Build-to-Deployment Workflow

Inspect and Build the Connector

Find Connector Classes and Configuration Settings

From the pinned checkout, use Git to find the implementation files for your deployment direction. TDengine’s sink example uses com.taosdata.kafka.TDengineSinkConnector.

# Run from the repository root.
git ls-files '*Connector*.java' '*Task*.java' '*Config*.java'
git grep -n -E 'ConfigDef|extends (Source|Sink)(Connector|Task)' -- '*.java'
git grep -n -E 'java.sql|DriverManager' -- '*.java'
git ls-files '*src/test/*' '*pom.xml' '*assembly*' '*descriptor*'
Source-map entry What to inspect in the returned paths Deployment role
Connector and task classes Source and sink implementations Define task creation and record processing
Configuration definitions ConfigDef declarations and property constants Identify accepted keys, defaults, and validation
Database-access code JDBC imports and client calls Show how the plugin communicates with TDengine
Tests Tracked test files and test configuration Show tested behavior and required external services
pom.xml and packaging descriptors Dependencies, plugins, and archive settings Determine what the distributable contains

These paths show which parts of the plugin to check before compiling, including what the package should contain.

Keep plugin properties, REST registration JSON, and worker settings separate. Plugin properties control TDengine connections and record handling. REST registration JSON supplies the connector name and a config object with connector.class and connector settings. Worker settings include plugin.path and offset-storage configuration for the Kafka Connect process - not the connector’s build files.

Build with Maven and Check the Package

The README lists Java 8+ and Maven 3.6+, but check both against the pinned build configuration. Include the previously recorded toolchain values in the build log.

java -version
mvn -version
git rev-parse HEAD

# Bash: retain the Maven exit status while saving its output.
set -o pipefail
mvn clean package 2>&1 | tee build.log

find target -type f \( -name '*.zip' -o -name '*.jar' \) -print

For TDengine’s documented 3.0 workflow, the ZIP appears under target/components/packages/. If your revision differs, use the actual build output. Inspect the full ZIP, not just the main JAR. Check its libraries against the Maven dependencies and packaging descriptors, including the required TDengine client libraries and metadata.

ls -lh target/components/packages/
for archive in target/components/packages/taosdata-kafka-connect-tdengine-*.zip; do
  [ -f "$archive" ] || continue
  unzip -l "$archive"
done

TDengine’s installation instructions use mvn clean package -Dmaven.test.skip=true. Use this variant only when the documentation requires it or an approved packaging-only workflow calls for it. It skips both test compilation and execution.

Save the build log, tool versions, commit SHA, archive listing, and archive checksum. A successful package does not establish runtime compatibility.

Troubleshoot Build Failures

Start with the first error in build.log. For compiler or class-version errors, compare the POM compiler settings with the output of java -version and mvn -version to spot a JDK mismatch.

For unresolved dependencies, check repository access, proxy settings, and inherited versions in pom.xml before changing dependencies. If classes or archive paths differ from what you expected, confirm the checkout before editing. Skipping tests will not fix missing compile-time dependencies reported in build.log.

git status
git describe --tags --always
mvn help:effective-pom -Doutput=effective-pom.xml

# Use debug logging only if the first error is still unclear.
mvn -X clean package > build-debug.log 2>&1

Once the build passes, move to plugin installation and runtime configuration.

Install and Configure the Plugin

With the package built, install that exact artifact on every worker.

Install the Package and Check Plugin Discovery

Install the verified ZIP from the pinned revision - not just the JAR. Extract the full package, including its dependent libraries, into a dedicated directory such as /opt/kafka/plugins/tdengine-kafka-connector/. Add that directory, or its parent, to the worker’s absolute plugin.path.

Use the same plugin directory on every distributed worker. Restart Kafka Connect after changing plugin.path; running workers do not reliably load new plugins.

# Set ARCHIVE to the verified ZIP from your build.
sudo mkdir -p /opt/kafka/plugins/tdengine-kafka-connector
sudo unzip "$ARCHIVE" -d /opt/kafka/plugins/tdengine-kafka-connector
plugin.path=/opt/kafka/plugins
curl -sS http://connect-worker.example.com:8083/connector-plugins

Query each worker directly. Check its logs for missing dependencies, Java-version errors, duplicate classes, and plugin initialization failures.

The endpoint lists only local plugins. Confirm the exact implementation class from your pinned revision: the documented sink and source classes differ, so their names are not interchangeable.

Once the worker discovers the plugin, use the smallest configuration that matches the pinned connector class.

Write a Minimal Connector Configuration

Save the configuration as tdengine-sink-test.json. Create the test database and grant access separately. Before registration, replace the password marker through your deployment’s supported secret mechanism.

Use the exact connector class from the pinned revision and only sink properties you’ve verified.

{
  "name": "tdengine-sink-test",
  "config": {
    "connector.class": "com.taosdata.kafka.connect.sink.TDengineSinkConnector",
    "tasks.max": "1",
    "topics": "meters",
    "connection.url": "jdbc:TAOS://tdengine-test.example.com:6030",
    "connection.user": "connector_test",
    "connection.password": "REPLACE_WITH_TEST_SECRET",
    "connection.database": "power"
  }
}
Setting What to verify
name, connector.class Use a stable instance name and the exact discovered implementation class.
tasks.max Start with 1. This sets a maximum; it does not guarantee parallel execution.
connection.url, connection.user, connection.password Use a reachable TDengine endpoint and dedicated nonproduction credentials.
connection.database Specify a database the account can access, such as power.
topics Use a sink input topic or topic selector supported by the pinned revision.
key.converter, value.converter Match the Kafka records. These Kafka Connect serialization settings do not define TDengine’s write format.

Register the configuration without exposing its secrets.

Register the Connector and Protect Credentials

Keep secrets out of Git, shell history, and logs. Use only worker-supported secret storage, restrict secret-file permissions, and grant the test account only the database permissions it needs.

Protect REST access with network controls, authentication, and TLS. The HTTP address below is for an isolated test network.

curl -sS -X POST \
  http://connect-worker.example.com:8083/connectors \
  -H 'Content-Type: application/json' \
  --data @tdengine-sink-test.json

curl -sS \
  http://connect-worker.example.com:8083/connectors/tdengine-sink-test/status

Check connector and task states, worker assignments, and error traces. For FAILED tasks, use the trace and worker logs to diagnose the problem before changing settings. A RUNNING task still needs an end-to-end record test.

Verify Features Before Deployment

Once the plugin is installed, test the exact artifact you plan to use in production.

Build a Feature Verification Matrix

Compare the pinned release documentation, code, and tests under src/test/java/com/taosdata/kafka/connect. Record the release or commit, TDengine, Kafka, Kafka Connect, Java, Maven, JDBC driver, and deployment mode.

Mark a capability supported only when documentation or code, together with an end-to-end test, confirms it. A successful build or connector registration isn't enough. Use unsupported for confirmed exclusions and unverified when evidence is missing.

Use the matrix as your test plan, then add the observed results. This structured approach is a core skill taught in our free data engineering boot camp.

Capability Evidence location Test result Deployment decision
Source or sink direction Release documentation, connector classes, configuration reference Pending Deploy only for the confirmed direction
TDengine and Kafka Connect versions Release notes, pom.xml, compatibility documentation Pending Proceed with validated versions
Stable and table mapping Source code, configuration properties, test tables Pending Follow documented naming rules
Topic naming Configuration reference and generated topic list Pending Proceed if names are acceptable
Poll and batch limits poll.interval.ms, fetch.max.rows, source implementation Pending Tune and retest
Serialization and data types Converter settings, serialization code, sample records Pending Require schema agreement
Authentication and connection recovery Configuration and failed-connection test Pending Document runtime requirements
Offsets, restart recovery, and duplicates Kafka offsets, worker logs, restart test Pending Accept only validated recovery behavior
Task distribution Task logs, worker status, source implementation Pending Keep tasks.max at the validated level

Test Records, Offsets, and Restart Recovery

For a confirmed source connector, load a small TDengine database with a stable, child tables, known timestamps, numeric values, strings, nulls if supported, and boundary cases.

Configure a topic prefix used only for this test and, where needed, topic.per.stable. The documented source example uses topic.prefix, topic.delimiter, topic.per.stable, and topic.ignore.db for routing.

Consume the resulting topics from a clean starting position. Check row counts, timestamps, precision, column order, names, null handling, numeric types, and stable or child-table identity. Documented source formats include InfluxDB Line Protocol and OpenTSDB JSON Protocol.

Record source offsets or sink consumer-group offsets before and after processing. Stop the worker after polling, restart it, and note whether records are skipped, replayed, or duplicated. Repeat the test after a connector restart and a simulated TDengine or Kafka outage. Use a composite key when timestamps alone can't distinguish records.

Report the observed behavior as at-least-once, possible replay, or another result backed by the tests. Don't call the connector exactly-once unless the implementation, Kafka Connect semantics, and failure tests together demonstrate that guarantee.

Test Task Distribution and Resource Limits

Set tasks.max to a small value. Inspect connector status and worker logs to identify the tables, topics, or work units each task owns. Increase the value in small steps and confirm that added tasks receive separate work.

Use enough independent tables or topics to see how work is distributed. Then compare per-task throughput, lag, CPU, memory, and connection counts. Check worker, connector, and task logs for authentication failures, conversion errors, timeouts, offset commits, and repeated polling.

Store the validated limits, sanitized configuration, metrics, logs, and artifact ID with the matrix for future upgrades.

Conclusion: Deployment Readiness Checklist

Approve the pinned build - not just the connection. Store the checksum, build date, install path, and rollback steps with the test evidence so the results can be reproduced.

Use the inspected source, built package, and runtime test results to make the release decision. Keep the verification matrix above as the sign-off record, and clear every item before deployment. For those looking to master data engineering and infrastructure best practices, these checklists are essential. Each check needs documented evidence; if anything is missing or unclear, keep the connector in test.

  • Versions recorded: Record the Git ref; TDengine server and JDBC driver versions; Kafka and Kafka Connect versions; Java runtime and Maven versions; and operating system. Confirm compatibility for the selected release rather than assuming it.
  • Package loadable: Confirm that mvn clean package succeeded and worker logs show plugin discovery through plugin.path.
  • Configuration reviewed: Fix the connector’s direction as source or sink, check settings against the inspected code, and keep credentials out of Git, shell history, and shared logs.
  • Runtime, capacity, and recovery validated: Confirm that task health, records, timestamps, mappings, offsets, restart behavior, task distribution, and resource use all met the acceptance criteria.
  • Scope approved: Exclude features that the inspected code and tests haven’t verified, unless a documented risk decision approves them.
  • Operational controls written down: Document monitoring, alerting, rollback, and log-retention procedures.

FAQs

Which connector class should I use if the examples differ?

Choose a connector class that supports your deployment’s version requirements and the features you need. Before you decide, check the connector’s official documentation to confirm that those features work with your target TDengine version.

Test your configuration in a sandbox to make sure the connector handles your data types and schemas correctly.

How can I prevent duplicate records after a restart?

Make processing idempotent at both the sink and application levels. Give each record a stable event ID and use business-level idempotency keys so the destination can identify and ignore duplicates replayed during processing.

Broker-level duplicate detection isn’t enough: receive-side logic must also be idempotent. Support exactly-once semantics where possible, and configure sink writes to handle duplicates safely - for example, through idempotent upserts.

How do I safely upgrade or roll back the connector?

Before upgrading or rolling back your TDengine Kafka connector, create a savepoint to record a consistent execution state. This lets you pause and resume processing without risking data loss.

Test the procedure in a controlled environment or dedicated R&D sandbox before changing production. Check that the pipeline handles failures correctly, including restarting from the last stable checkpoint to protect data integrity.