试图实现一个 Flink 作业来读取 Kafka 流和聚合会话,由于某种原因 getResult() 没有被调用。我看到 createAccumulator() 和 add() 被调用,我期待 getResult() 也被调用,以便我可以在目的地接收聚合消息。
source.keyBy(new KeySelector<GenericRecord, String>() {
@Override
public String getKey(GenericRecord record) {
return record.get("id").toString();
}})
.assignTimestampsAndWatermarks(new AssignerWithPunctuatedWatermarks<GenericRecord>() {
private static final long serialVersionUID = -4834111073247835189L;
private final long maxTimeLag = 300000L;
@Nullable
@Override
public Watermark checkAndGetNextWatermark(GenericRecord lastElement, long extractedTimestamp) {
return new Watermark(extractedTimestamp - maxTimeLag);
}
@Override
public long extractTimestamp(GenericRecord element, long previousElementTimestamp) {
long ts = 1000 * (long)element.get(("timestamp"));
return (ts);
}
})
.map(new ReduceAttributesMap())
.keyBy(new KeySelector<Tuple2<String, String>, String>() {
@Override
public String getKey(Tuple2<String, String> e) {
return e.f0;
}
})
.window(EventTimeSessionWindows.withGap(Time.minutes(5)))
.aggregate(new EventAggregation())
.addSink(...)
可能是什么问题?我配置错误了吗?感谢你的帮助!