I am reading messages from a Kafka topic with 2 partitions and using event time. This is my code:
stream.assignTimestampsAndWatermarks(new AscendingTimestampExtractor<Request>() {
@Override
public long extractAscendingTimestamp(Request req) {
return req.ts;
}
})
.windowAll(TumblingEventTimeWindows.of(Time.days(1)))
.apply((TimeWindow window, Iterable<Request> iterable, Collector<String> collector) -> {
collector.collect("Window: " + window.toString());
for (Request req : iterable) {
collector.collect(req.toString());
}
})
.print()
I could get an output only when setting the Kafka source parallelism to 1. According to this thread , I guess that is because messages from multiple partitions arrive out-of-order to the timestamp extractor.
So I replaced the AscendingTimestampExtractor
with a BoundedOutOfOrdernessGenerator
as in this documentation example (with a higher maxOutOfOrderness delay), in order to handle out-of-order events, but I still can't get any output. Why is that?
Check that the event timestamp is OK. Must have a 13 length to be used in Flink Java Epoch.
Correct : 1563743505673
Incorrect : 1563743505
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.