A fluent interface is an API design pattern that chains method calls into a concise, readable expression. In Kafka Streams, transformations return a new KStream or KTable, so each result can become the receiver for the next operation. section 6.3.1 section 6.2
A Kafka Streams chain typically follows this sequence:
- Read records from a topic with builder.stream and Consumed serializers/deserializers. section 6.3.1
- Transform values with an operation such as mapValues, receiving another stream. section 6.3.1
- Write the final stream to a topic with to and Produced serializers/deserializers. section 6.3.1
- Use named intermediate variables when chaining would reduce clarity. section 6.3.1
Uppercase a Kafka stream
KStream<String, String> result = builder.stream("src-topic", Consumed.with(Serdes.String(), Serdes.String())) .mapValues(value -> value.toUpperCase()); result.to("out-topic", Produced.with(Serdes.String(), Serdes.String())); The equivalent fluent form chains the complete topology: builder.stream("src-topic", Consumed.with(Serdes.String(), Serdes.String())).mapValues(value -> value.toUpperCase()).to("out-topic", Produced.with(Serdes.String(), Serdes.String())). section 6.3.1
builder.stream("src-topic", Consumed.with(Serdes.String(), Serdes.String()))
.mapValues(value -> value.toUpperCase())
.to("out-topic", Produced.with(Serdes.String(), Serdes.String()));
Inspect the complete one-expression topology to compare fluent chaining with the three-statement version. section 6.3.1



