繁体   English   中英

使用 Apache Beam 的 Fixed Windowing 仅触发一次元素

[英]Trigger elements exactly once using Fixed Windowing with Apache Beam

我正在从 Google pub-sub 读取数据并将它们窗口化为 5 分钟的固定 window。 但是 - 数据未正确触发。 我尝试了多种组合,似乎没有任何效果。 这看起来相当简单 - 但我无法正确处理。

用例 -

  1. 从 pub-sub 读取数据
  2. Window 把它们变成5分钟
  3. 在 5 分钟 window 结束后执行聚合。
  4. AllowedLateness 1 天。

尝试:

1.使用AfterWatermark.pastEndOfWindow触发。 这根本不会产生任何 output。 从订阅中读取了大约 1000 条消息,但 window 没有输出消息。

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 或 Late Firings - 触发一些元素但不适合我的用例 - 我不需要提前或延迟触发 - 只需要每 5 分钟一次的结果。

任何输入都会非常有帮助,我在这方面投入了太多时间,但没有运气。

发现问题:

这是 DirectRunner 的错误。 出于某种原因 - 直接跑步者没有推进水印,因此没有触发任何事情。

以下代码正常工作 - 使用 Dataflow Runner - 在 window 结束后触发元素。

Window<MyModel> window = Window.<MyModel>into(FixedWindows.of(Duration.standardMinutes(10)))
                    .triggering(Repeatedly.forever(AfterWatermark.pastEndOfWindow()))
                    .withAllowedLateness(Duration.standardDays(1))
                    .discardingFiredPanes();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM