Filtering selects records from a continuous stream by applying a predicate to each message. Only records for which the predicate returns true continue through the stream. section 12.2.1
Keep significant price changes
For a stream of product price changes, retain only messages whose new price exceeds $100: filter((key, value) -> value.price > 100). Lower-priced changes are discarded, while qualifying records preserve their existing key and value. section 12.2.1
filter((key, value) -> value.price > 100)
Use the concise Kafka Streams predicate to inspect the value of every record and retain qualifying price changes. section 12.2.1
Apply filtering with these boundaries in mind:
- Use map() or mapValues() when records must be changed; filter() only selects records. section 12.2.1
- Chain filters to create categories such as cheap, midrange, and expensive prices, or use split() to branch a stream into destinations. section 12.2.1
- Prefer mapValues() when changing only values, because changing keys can require repartitioning and reduce performance. section 12.2.1
































