0
0
Kafkadevops~10 mins

Common connectors (JDBC, S3, Elasticsearch) in Kafka - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Common connectors (JDBC, S3, Elasticsearch)
Kafka Source Topic
Connector Configuration
Connector Plugin
JDBC
Data Sink
Data flows from Kafka through a connector configured to send data to JDBC, S3, or Elasticsearch sinks.
Execution Sample
Kafka
name=jdbc-sink-connector
connector.class=io.confluent.connect.jdbc.JdbcSinkConnector
topics=my_topic
connection.url=jdbc:postgresql://localhost:5432/mydb
insert.mode=insert
This config sets up a JDBC sink connector to write Kafka topic data into a PostgreSQL database.
Process Table
StepActionConnectorInputOutputResult
1Read message from Kafka topicAllKafka messageMessage dataMessage ready for processing
2Apply connector configJDBCMessage dataSQL Insert statementPrepared SQL for DB
3Send data to sinkJDBCSQL Insert statementDatabase rowData stored in DB
4Read message from Kafka topicS3Kafka messageMessage dataMessage ready for processing
5Apply connector configS3Message dataFile objectData formatted for S3
6Send data to sinkS3File objectS3 bucket fileData stored in S3
7Read message from Kafka topicElasticsearchKafka messageMessage dataMessage ready for processing
8Apply connector configElasticsearchMessage dataJSON documentData formatted for ES
9Send data to sinkElasticsearchJSON documentES index documentData indexed in ES
10No more messagesAll--Connector idle, waiting for new messages
💡 No more messages in Kafka topic, connectors wait for new data.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7After Step 8After Step 9Final
MessageNoneKafka messageMessage dataSQL Insert statementNoneKafka messageFile objectNoneKafka messageJSON documentNone
Data SinkEmptyEmptyEmptyDatabase rowEmptyEmptyS3 bucket fileEmptyEmptyES index documentIdle
Key Moments - 3 Insights
Why does the message variable reset to None after sending to the sink?
After the connector sends data to the sink (see steps 3, 6, 9), the message is processed and cleared to prepare for the next message, as shown in the execution_table.
How does the connector know which sink to send data to?
The connector.class setting in the configuration (see execution_sample) determines which sink plugin is used, directing data to JDBC, S3, or Elasticsearch accordingly.
Why are there repeated steps for reading messages in the execution_table?
Each connector independently reads messages from Kafka to process them for its sink, so steps repeat for JDBC, S3, and Elasticsearch connectors separately.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output after step 5?
ASQL Insert statement
BFile object
CJSON document
DDatabase row
💡 Hint
Check the 'Output' column for step 5 in the execution_table.
At which step does the data get stored in Elasticsearch?
AStep 9
BStep 6
CStep 3
DStep 10
💡 Hint
Look for 'Data indexed in ES' in the 'Result' column of the execution_table.
If the connector.class is changed to S3, which steps would no longer occur?
ASteps 4 and 5
BSteps 7 and 8
CSteps 2 and 3
DSteps 1 and 10
💡 Hint
Refer to the 'Connector' column in the execution_table to see which steps belong to JDBC.
Concept Snapshot
Common Kafka connectors move data from Kafka topics to external systems.
Use connector.class to select sink: JDBC for databases, S3 for storage, Elasticsearch for search.
Connectors read messages, transform data, then write to the sink.
Each connector runs independently but follows the same flow: read, transform, write.
Configure connectors with properties like topics, connection URLs, and modes.
Full Transcript
This visual execution shows how Kafka connectors work to move data from Kafka topics to external systems like JDBC databases, S3 storage, and Elasticsearch indexes. The flow starts with reading messages from Kafka, applying connector-specific configurations, transforming the data into the required format, and finally sending it to the sink. Each connector type (JDBC, S3, Elasticsearch) processes messages independently but follows the same steps. Variables like 'Message' and 'Data Sink' change as data moves through the steps. Key moments clarify why messages reset after sending and how connectors know their sink. The quiz tests understanding of outputs at different steps and connector behavior. This helps beginners see the step-by-step data movement in Kafka connectors.