liveBook · Manning

Flink Kafka connector

As explained in Apache Kafka in Action

A Flink Kafka connector is a connector component that enables Apache Flink to read data from or write data to Kafka.

A Flink Kafka connector links a Flink dataflow to Kafka, letting Flink read topic data, process it continuously, and write results back to Kafka. In an online product-price pipeline, the connector can expose price changes to Flink SQL or downstream consumers. section 12.2.1 section 12.3

Configure the connection around these decisions:

  • Declare Kafka as the connector and provide the bootstrap server, topic, and data format. section 12.3
  • Map message fields and keys explicitly when the Kafka record key carries business identity such as product_id. section 12.3
  • Treat Flink SQL queries as continuous operations rather than one-time database queries; write results back to Kafka when consumers need them. section 12.3

Product-price change stream

Create a Kafka-backed table for products.prices.changelog, filter rows where price exceeds 100, or continuously count price changes grouped by product_id. The same connector pattern supports sending processed results to another Kafka topic. section 12.2.1 section 12.3

CREATE TABLE productprices (
  product_id INT,
  product_name STRING,
  price FLOAT,
  oldPrice FLOAT
) WITH (
  'connector' = 'kafka',
  'topic' = 'products.prices.changelog',
  'properties.bootstrap.servers' = 'localhost:9092',
  'format' = 'json',
  'key.format' = 'json',
  'key.fields' = 'product_id',
  'value.fields-include' = 'EXCEPT_KEY'
);

Inspect the complete Flink SQL CREATE TABLE definition, including the Kafka connector, topic, bootstrap server, JSON format, and key-field settings. section 12.3

How Apache Kafka in Action covers it

How deep it goes
Explains connector configuration, key mapping, formats, and continuous queries, but defers broader SQL and operational detail.
Examples
Uses a product-price changelog, price filtering, per-product counting, and writing processed streams to Kafka topics.
What you can do after
Operate/configure Flink SQL tables that consume Kafka topics, process records continuously, and expose results to Kafka consumers.
How it connects
Connects Kafka with Apache Flink, Flink SQL, stream processing, JSON, and Kafka Connect.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.