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
