liveBook · Manning

Consumed

As explained in Kafka Streams in Action, Second Edition

Consumed is a Kafka Streams configuration object that specifies input serializers and deserializers and other settings for a source node.

Consumed is a Kafka Streams configuration object for a source node. It supplies the key and value Serdes that deserialize broker-stored byte arrays into application objects, and can also configure timestamp extraction, offset reset behavior, and an operator name. section 6.3.1

Use Consumed when creating an input stream or table:

  • Configure a single-topic source with builder.stream("src-topic", Consumed.with(Serdes.String(), Serdes.String())). section 6.3.1
  • Apply the same input configuration while subscribing to several topics through a collection of topic names. section 6.3.1
  • Subscribe to matching topic names with a regular expression and the same Consumed configuration. section 6.3.1
  • Pass the supplied Serdes into a KTable's state store when creating the table from a topic. section 8.2

A string source for the Yelling application

KStream<String, String> simpleFirstStream = builder.stream("src-topic", Consumed.with(Serdes.String(), Serdes.String())); The first Serde deserializes record keys and the second deserializes values. The resulting stream can continue through processors such as mapValues before writing to an output topic. section 6.3.1

Listing 6.1 Defining the source for the stream
KStream<String, String> simpleFirstStream = builder.stream("src-topic",
Consumed.with(Serdes.String(), Serdes.String()));

Browse the source-node listing showing Consumed.with with String Serdes. section 6.3.1

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains source-node role, Serde-based deserialization, topic subscriptions, and optional settings without detailing Serde internals.
Examples
Uses string streams, multiple topics, regular-expression subscriptions, and a stock-trade KTable backed by a custom Serde.
What it assumes
Assumes Kafka broker records use byte arrays and introduces how Serdes convert those bytes into concrete stream or table objects.
What you can do after
Build it from scratch by configuring typed Kafka Streams inputs and topic-backed tables with appropriate Serdes.
How it connects
Connects Consumed to Kafka Streams source nodes, Serdes, KStream, KTable, StateStore, TimestampExtractor, and offset reset.

Related concepts

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