I'm creating a pipeline which ingests unbounded data source and does an aggregation computation. The computation is done in 10 minutes window based on event time and 5 minutes buffer for late-arriving events. I want to have the result of aggregation is emitted only once after that 10 minutes window and 5 minutes buffer passed.
I don't know how to make the window only emit the result once. I believe the correct way is using AfterWatermark
trigger but If I'm using withLateFirings()
the result will be emitted twice after the window passed and after late firing duration passed. If late firing is not used, the late events will not be included in the computation, this doesn't fulfill my requirements.
public class WindowFactory {
private static final Duration FIVE_MINUTES = Duration.standardMinutes(5);
public static Window<Message> getMessageFixedWindow(Duration duration) {
return Window.<Message>into(FixedWindows.of(duration))
.triggering(
AfterWatermark
.pastEndOfWindow()
.withLateFirings(
AfterProcessingTime
.pastFirstElementInPane()
.plusDelayOf(FIVE_MINUTES)))
.discardingFiredPanes()
.withAllowedLateness(FIVE_MINUTES);
}
}
Please suggest me the good way to only produce 1 result after 10 minute windows and 5 minutes buffer.