THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
KStream looks a lot like java.util.stream.Stream
; it includes methods such as filter
and map
, terminal operations like to
or join
, and so on. One conspicuously absent method is peek
.e
Most stream operations are expected to be pure functions. peek
, by its nature, is not. Usually mutating external state is discouraged but a number of diagnostic activities are made much easier.
...
Code Block | ||
---|---|---|
| ||
KStream<String> words = someWordsWeWantToCount(); // since this is what basically every kafka application does, right? :) wordCounts.filter(w -> w.startsWith("a")) .peek(w -> metrics.wordsStartingWithAwordsStartingWithAProcessed.increment()) .peek(System.out::println) .groupByKey().count(); |
...