shetc (31) [Avatar] Offline
If I try Listing 3.2 (Mapping incoming text to uppercase)

KStream<String, String> upperCasedStream = [CA]simpleFirstStream.mapValues(String::toUpperCase);

with kafka-streams-2.0.0, it produces the error:

The method mapValues(ValueMapper<? super String,? extends String>) is ambiguous for the type KStream<String,String>

This appears to work:

        KStream<String, String> upperCasedStream = simpleFirstStream.mapValues(new ValueMapper<String, String>() {
            public String apply(String value) {
                return value.toUpperCase();

Also, this constructor is deprecated:
StreamsConfig streamsConfig = new StreamsConfig(props);
KafkaStreams kafkaStreams = new KafkaStreams(, streamsConfig);

This is not:

KafkaStreams kafkaStreams = new KafkaStreams(, props);

Bill Bejeck (47) [Avatar] Offline
Hi Shetc,

Thanks for commenting. The code for the book is version 1.0.0. Since the 1.0.0 release, there have been some changes, including depreciation of some methods.

For ambiguous compiler issue, mapValues now accepts a ValueMapper that accepts either the value by itself or a key and value for modifying the value. Thus using a method handle give an ambiguous compiler error. In 2.0 you won't be able to use method handles anymore for mapValues and you'll need to do either (k, v) -> .... or (v) -> .....



shetc (31) [Avatar] Offline
Hi Bill,

Thanks for the response. I'm just starting a project where we want to use Kafka Streams, but in a fairly simplistic way just to get our feet wet. WIll reverting back to version 1 be an issue?