在Kafka Streams中编写跳转窗口时出现编译错误(Confluent 4.0.0)

时间:2017-12-12 05:18:01

标签: apache-kafka apache-kafka-streams confluent

我正在尝试在Confluent open source 4.0.0版本的时间窗口上编写聚合操作,如下所示。

KTable<Windowed<String>, aggrTest> testWinAlerts =
    testRecords.groupByKey()
               .windowedBy(TimeWindows.of(TimeUnit.SECONDS.toMillis(120))
                                      .advanceBy(TimeUnit.SECONDS.toMillis(1)))
               .aggregate(
                   new aggrTestInitilizer(), 
                   new minMaxCalculator(),
                   Materialized.<String, aggrTest, WindowStore<Bytes, byte[]>>
                       as("queryable-store-name")
                           .withValueSerde(aggrMessageSerde)
                           .withKeySerde(Serdes.String()));

但是上面的代码在编译时会出错,如下所示

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    The method aggregate(Initializer<VR>, Aggregator<? super String,? super TestFields,VR>, Materialized<String,VR,WindowStore<Bytes,byte[]>>) in the type TimeWindowedKStream<String,TestFields> is not applicable for the arguments (aggrTestInitilizer, minMaxCalculator, Materialized<String,aggrTest,WindowStore<Bytes,byte[]>>)

当我在3.3.1版本中编写如下代码时,它没有给出任何错误

KTable<Windowed<String>, aggrTest> testWinAlerts =
    testRecords.groupByKey()
               .aggregate(
                   new aggrTestInitilizer(),
                   new minMaxCalculator(),
                   TimeWindows.of(TimeUnit.SECONDS.toMillis(120))
                              .advanceBy(TimeUnit.SECONDS.toMillis(1)),
                   aggrMessageSerde,
                   "aggr-test");

可能会出现什么问题?在所有情况下使用的aggrTestInitilizer, minMaxCalculator, aggrMessageSerde也是相同的。

0 个答案:

没有答案