Hi Barry,
First thing, make sure you configured the engine in STREAM mode. Check KnowledgeBaseConfiguration for that.
Second, if you are not using trunk, i.e., you are using for instance 5.0.1, set an expiration policy for your event that is >= your sliding window:
declare MarketDataEvent
@role(event)
@expires( 10s )
end
Run your test and you should be fine.
Additional info: in 5.0.1, there was a bug on expiration offset calculation for sliding windows. The work around is explicitly setting the expiration policy as above. That was fixed some time ago and will be in next release.
Also, in 5.0.1 we don't have batch windows. Only sliding windows. We are adding batch windows for the next release.
Let me know how it goes.
[]s
Edson
2009/8/29 Barry Kaplan
<groups1@memelet.com>
I've been using esper for some time with great success. But the appeal of
having integrated rules is overwhelming. To get familiar with Fusion, I'm
trying to implement the esper patterns, yet I and am stuck on the very first
one:
How do I measure the rate of arrival of events in a given time period?"
-> "select count(*) as cnt from MarketDataEvent.win:time_batch(1 second)"
For now I'm just trying to get my rule to fire at all, so its not really
trying to count just trigger when the number events in the window exceeds a
certain number. (But I admit, I'm not sure how to just the get running count
over the window, so if anybody knows...):
declare MarketDataEvent
@role(event)
end
rule "How do I measure the rate of arrival of events in a given time
period?"
when
$count : Long( longValue > 5) from accumulate (
$e: MarketDataEvent() over window:time(1s) from entry-point
"stream", count($e))
then
System.out.println("***** > 5");
end
My test driver is just inserting events every 10ms:
(1..10).each {
drools.clock.advanceTime(10, TimeUnit.MILLISECONDS)
drools.entryPoint.insert(new MarketDataEvent(it as String))
drools.session.fireAllRules()
}
If I do /not/ advance the clock, then I rule fires each time after the 5th
insert. But if the clock /is/ advanced (at any increment) then the rule
never fires.
Any clues what I might be missing?
thanks!
--
View this message in context: http://www.nabble.com/clock.advanceTime-behaviour--tp25205578p25205578.html
Sent from the drools - user mailing list archive at Nabble.com.
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com