Reputation: 11
Currently i try looking into storm for message processing. I find the sliding window feature interesting and tried getting it to work.
But even if i set the interval to say like 5 seconds, the computation behind the window is done much more frequent. It seems with every new message the execute-method for the tuple window gets executed.
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");
Someone has an idea why? I want the computation to wait for all messages in the 5 seconds interval.
Upvotes: 1
Views: 749
Reputation: 408
I think the reason is that you are using SlidingWindow - which generates an output for every entry and exit in that window. If you want only one output at the end of the window then you should ideally be using Batch windows or Tumbling windows. To summarise:
Upvotes: 0
Reputation: 3260
You must use withTumblingWindow
instead withWindow
.
withWindow
executes on every input tuple and deliver an input batch that contains last input messages. but withTumblingWindow
will aggregate all input messages in a batch and delivers whole-in-one.
Upvotes: 2