【发布时间】:2016-09-25 19:57:51
【问题描述】:
目前我尝试调查风暴以进行消息处理。我发现滑动窗口功能很有趣,并尝试让它发挥作用。
但即使我将间隔设置为 5 秒,窗口后面的计算也会更加频繁。似乎每条新消息都会执行元组窗口的执行方法。
builder.setBolt("messageCountBolt",
new MessageCountBolt()
.withWindow(
new BaseWindowedBolt.Duration(20, TimeUnit.SECONDS),
new BaseWindowedBolt.Duration(5, TimeUnit.SECONDS))
.withMessageIdField("id")
.withTimestampField("timeStamp")
.withLag(new BaseWindowedBolt.Duration(5, TimeUnit.SECONDS)),
1).globalGrouping("spout");
有人知道为什么吗?我希望计算等待 5 秒间隔内的所有消息。
【问题讨论】:
-
我认为解决这个问题的正确方法是在 Storm 之上使用 Trident,因为每条新消息都会触发对普通 Storm 中的 execute 方法的调用。
标签: apache-storm sliding-window