liveBook · Manning

Single message transformation

As explained in Apache Kafka in Action

A single message transformation is a Kafka Connect transformation that modifies an individual record as it passes through a source or sink connector.

A single message transformation (SMT) modifies each record as it moves through a Kafka Connect source or sink connector. It handles focused changes such as renaming fields, masking data, or moving a value into the key. section 11.7 section 11.10

For a source connector, the transformation runs after external data becomes Kafka Connect’s internal structure and before the record is written to Kafka. For a sink connector, it runs after topic data is converted internally and before the sink receives it. section 11.7

Configure SMTs as an ordered pipeline in the connector JSON sent to the Kafka Connect REST API:

  • List transformation names in the transforms property, choosing names such as rename or extractKey. section 11.7
  • Declare each transformation’s Java class with transforms.<name>.type and add its specific settings. section 11.7
  • Rely on the comma-separated list to determine execution order. section 11.7

Rename and extract a product identifier

A ReplaceField transformation can exclude dropme and rename foo to bar. A ValueToKey transformation can move product_id from the value into the key, followed by ExtractField$Key to retain that field as the key.

SMTs are deliberately narrow. Avoid using them as a full ETL layer; complex transformations belong in Kafka Streams or another stream-processing framework. section 11.7

How Apache Kafka in Action covers it

How deep it goes
Explains execution placement, ordered JSON configuration, and common transformations, but stops short of complex ETL design.
Examples
Demonstrates ReplaceField, ValueToKey, ExtractField, field renaming, field removal, and product_id key extraction.
What it assumes
Builds on Kafka Connect connector configuration and JSON properties rather than teaching connector operation from zero.
What you can do after
Configure ordered SMT pipelines through Kafka Connect’s REST API for simple source or sink record changes.
How it connects
Connects Kafka Connect with source connectors, sink connectors, ETL, Kafka Streams, and stream processing.

Also explained in

Compare how 2 books explain single message transformation →

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.