【发布时间】:2020-11-22 09:30:33
【问题描述】:
我正在从 Google pub-sub 读取数据并将它们窗口化为 5 分钟的固定窗口。但是 - 数据未正确触发。我尝试了多种组合,似乎没有任何效果。这看起来相当简单 - 但我无法正确处理。
用例 -
- 从 pub-sub 读取数据
- 将它们窗口化为 5 分钟
- 在 5 分钟窗口结束后执行聚合。
- AllowedLateness 为 1 天。
尝试:
1.使用AfterWatermark.pastEndOfWindow触发。这根本不会产生任何输出。从订阅中读取了大约 1000 条消息,但窗口没有输出任何消息。
Window.<EventModel>into(
FixedWindows.of(Duration.standardMinutes(5)))
.triggering(AfterWatermark.pastEndOfWindow())
.withAllowedLateness(Duration.standardDays(1), Window.ClosingBehavior.FIRE_ALWAYS)
.discardingFiredPanes();
2.使用全局窗口:这可以正常工作。但这使用 GlobalWindows - 但我需要实现固定窗口。
Window<EventModel> window = Window.<OrderEvent>
into(new GlobalWindows())
.triggering(
Repeatedly.forever(
AfterProcessingTime.pastFirstElementInPane().plusDelayOf(Duration.standardMinutes(5))))
.discardingFiredPanes()
.withAllowedLateness(Duration.standardDays(1));
我尝试了其他组合使用 - Early Firings 或 Late Firings - 触发一些元素但不适合我的用例 - 我不需要提前或延迟触发 - 只需要每 5 分钟一次的结果。
任何意见都会非常有帮助,我在这方面投入了太多时间,但没有运气。
【问题讨论】:
标签: java google-cloud-platform apache-beam google-cloud-pubsub windowing