[rules-users] Problem with time sliding windows and pseudo clock in Drools Fusion 5.5.0

martinzp martinzp at gmail.com
Fri Dec 6 17:54:19 EST 2013


Hi, i am new in the forum, and a beginner user of Drools so forgive me if my
question isn't quite good.

I want to test the "over window:time" operand.

In order to do that i use the pseudo clock, but i have noticed that it
doesn't behave as i would expect.

The behaviour i think i observed, is that the rule is using the real clock
instead of the pseudo clock.

*Here is my drl file:*

rule "Fire Detected"
when
    c : Number(intValue >= 3) from accumulate (
        $tr : TemperatureRead(read > 40)
            over window:time ( 1s )
            from entry-point entryone ,
            count ($tr)
             )
then
    System.out.println("Fire Detected!");
end



*and here is the portion of my main file that inserts the events:*

TemperatureRead temp1 = new TemperatureRead(33.2);
TemperatureRead temp2 = new TemperatureRead(38.7);
TemperatureRead temp3 = new TemperatureRead(39.5);
TemperatureRead temp4 = new TemperatureRead(42.5);
TemperatureRead temp5 = new TemperatureRead(43.1);
TemperatureRead temp6 = new TemperatureRead(47.8);

SessionPseudoClock clock = ksession.getSessionClock();
        
        entryPoint1.insert(temp1);
        
        clock.advanceTime((new Date()).getTime(), TimeUnit.MILLISECONDS);
        
        fireRules();
        
        entryPoint1.insert(temp2);
        
        clock.advanceTime(1, TimeUnit.SECONDS);
        
        fireRules();
        
        entryPoint1.insert(temp3);
        
        clock.advanceTime(1, TimeUnit.SECONDS);
        
        fireRules();
        
        entryPoint1.insert(temp4);
        
        clock.advanceTime(1, TimeUnit.SECONDS);
        
        fireRules();
        
        entryPoint1.insert(temp5);
        
        clock.advanceTime(1, TimeUnit.SECONDS);
        
        fireRules();
        
        entryPoint1.insert(temp6);
        
        fireRules();





In my opinion, the rule shouldn't be fired, because as i am (supposedly)
using the pseudo clock, the events shouldn't fall into the same sliding
window (1 second.)

In general, the rule should fire when it detects 3 or more temperature reads
with a temperature over 40.

Any idea about what i might be doing wrong?

Thanks in advance!







--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-time-sliding-windows-and-pseudo-clock-in-Drools-Fusion-5-5-0-tp4027137.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list