0Pricing
Apache Kafka & Stream Processing Fundamentals · บทเรียน

ตัวเชื่อมต่อปลายทางสำหรับการส่งออก

สำรวจวิธีใช้ตัวเชื่อมต่อปลายทางเพื่อส่งออกข้อมูลจากหัวข้อ Kafka ไปยังฐานข้อมูล ทะเลสาบข้อมูล และปลายทางอื่น ๆ

ตัวเชื่อมต่อปลายทางสำหรับการส่งออก เป็นบทเรียน Apache Kafka & Stream Processing Fundamentals ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Apache Kafka & Stream Processing Fundamentals และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Apache Kafka & Stream Processing Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Exporting Data from Kafka

Welcome to the final lesson on Kafka Connect! We've learned how to bring data into Kafka using Source Connectors. Now, let's explore how to get data out.

This lesson focuses on Sink Connectors, which are essential for moving data from your Kafka topics to external systems like databases, data warehouses, or analytics platforms.

Why Use Sink Connectors?

Imagine you have real-time data streaming into Kafka, but your business intelligence tools or legacy applications need that data in a different system.

  • Integration: Connect Kafka to almost any data store.
  • No Custom Code: Avoid writing complex consumer applications for common destinations.
  • Reliability: Built-in fault tolerance and delivery guarantees.
  • Scalability: Easily scale data export by adding more connector tasks.

How Sink Connectors Function

A Sink Connector acts like a specialized Kafka consumer. Here's the basic workflow:

  1. The connector runs within a Kafka Connect worker.
  2. It subscribes to one or more Kafka topics.
  3. It consumes messages from these topics.
  4. It transforms (if configured) and writes the data to the target external system.
  5. It manages Kafka offsets, ensuring data is processed reliably.

Common Sink Destinations

Kafka Connect offers a rich ecosystem of pre-built sink connectors for a wide variety of destinations. Some popular examples include:

  • Databases: PostgreSQL, MySQL, Oracle, SQL Server (via JDBC)
  • Cloud Storage: Amazon S3, Google Cloud Storage, Azure Blob Storage
  • Search Engines: Elasticsearch, Solr
  • Data Warehouses: Snowflake, Redshift
  • Other Systems: HDFS, JMS queues, HTTP endpoints

Basic Sink Connector Configuration

Configuring a sink connector is similar to source connectors. You define its properties in a JSON file or directly via the Connect REST API. Key properties include:

  • name: Unique name for your connector.
  • connector.class: The specific connector implementation (e.g., JdbcSinkConnector).
  • topics or topics.regex: The Kafka topics to read from.
  • key.converter & value.converter: How to deserialize data from Kafka.

Example: FileStreamSinkConnector

Let's look at a simple example: the FileStreamSinkConnector. This built-in connector writes data from a Kafka topic to a local file. It's great for observing how sink connectors work.

Here's a basic configuration JSON for it:

{ "name": "file-sink-connector",
  "config": {
    "connector.class": "org.apache.kafka.connect.file.FileStreamSinkConnector",
    "tasks.max": "1",
    "topics": "my_test_topic",
    "file": "/tmp/kafka-sink-output.txt",
    "key.converter": "org.apache.kafka.connect.storage.StringConverter",
    "value.converter": "org.apache.kafka.connect.storage.StringConverter"
  }
}

Deploying a Sink Connector

Once you have your connector configuration (like the file-sink-config.json above), you deploy it to your Kafka Connect cluster using a curl command against the Connect REST API:

This command tells the Connect cluster to create and start a new connector instance based on your configuration.

curl -X POST -H "Content-Type: application/json" \
  --data @file-sink-config.json \
  http://localhost:8083/connectors

Data Formats and Converters

When a sink connector reads data from Kafka, it uses converters to deserialize the message keys and values. Common converters include:

  • StringConverter: For plain text data.
  • JsonConverter: For JSON formatted data.
  • AvroConverter: For Avro-serialized data (often with Schema Registry).

The connector then takes this deserialized data and formats it appropriately for the target system (e.g., SQL INSERT statements for a database sink).

Ensuring Data Integrity

Kafka Connect sink connectors are designed for reliability:

  • At-Least-Once Delivery: Most sink connectors guarantee that each message will be delivered to the destination at least once, even if failures occur.
  • Offset Management: Connectors automatically commit offsets to Kafka, tracking what data has been successfully processed.
  • Error Handling: Connectors can be configured to retry failed operations or send problematic messages to a Dead Letter Queue (DLQ) for later inspection.

Sink Connector Challenge

Let's check your understanding of Kafka Connect Sink Connectors!

Recap: Sink Connectors

Great job! You've now grasped the core concepts of Kafka Connect Sink Connectors.

  • Sink Connectors export data from Kafka topics to various external systems.
  • They provide a reliable, scalable, and code-free way to integrate Kafka with your data ecosystem.
  • Configuration involves specifying the connector class, topics, and destination-specific properties.
  • They handle data deserialization, formatting, and ensure delivery guarantees.

Kafka Connect significantly simplifies building robust data pipelines!

คำถามที่พบบ่อย

บทเรียน “ตัวเชื่อมต่อปลายทางสำหรับการส่งออก” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ตัวเชื่อมต่อปลายทางสำหรับการส่งออก” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Apache Kafka & Stream Processing Fundamentals ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Apache Kafka & Stream Processing Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ตัวเชื่อมต่อปลายทางสำหรับการส่งออก”

สำรวจวิธีใช้ตัวเชื่อมต่อปลายทางเพื่อส่งออกข้อมูลจากหัวข้อ Kafka ไปยังฐานข้อมูล ทะเลสาบข้อมูล และปลายทางอื่น ๆ คุณปฏิบัติ Apache Kafka & Stream Processing Fundamentals ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Apache Kafka & Stream Processing Fundamentals หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Apache Kafka & Stream Processing Fundamentals บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “ตัวเชื่อมต่อปลายทางสำหรับการส่งออก” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Apache Kafka & Stream Processing Fundamentals นี้ได้ไหม

ได้ บทเรียน Apache Kafka & Stream Processing Fundamentals ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. บทนำสู่ Kafka Connect
  2. ตัวเชื่อมต่อแหล่งข้อมูลสำหรับการนำเข้า
  3. ตัวเชื่อมต่อปลายทางสำหรับการส่งออก
  4. การแปลงข้อความเดี่ยว (SMTs)
← กลับไปที่ Apache Kafka & Stream Processing Fundamentals