[rules-users] clock.advanceTime behaviour?

Barry Kaplan groups1 at memelet.com
Sat Aug 29 18:59:44 EDT 2009


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.




More information about the rules-users mailing list