Hi, I am having trouble understanding how to use sliding windows. Here are
the relevant snippets of code I added to the Hello World example under
Drools Fusion. I also added a timestamp to the Message class (with
corresponding get and set functions).

DroolsTest.java:

for(int i=0; i < 6; i++) {
        Thread.sleep(10000);
        currDate = new Date();
        Message message = new Message();
        message.setMessage("Hello World");
        message.setStatus(Message.HELLO);
        message.setTemporalStamp(currDate);
        ksession.insert(message);
}                       
ksession.fireAllRules();

Sample.drl:

declare Message
    @role( event )
    @timestamp( temporalStamp )
end 
 
rule "Hello World"
        when
                m : Message( status == Message.HELLO, myMessage : message, ts :
temporalStamp ) over window:time( 15s )
        then
                System.out.println( myMessage + ": In the 1 minute window with 
timestamp:
" + ts );
End

My intention was to print out all messages with status = HELLO AND within 15
seconds of inserting the message into the session.
I thought what would happen is 2 out of the 6 Messages I sent would be
printed out. But, instead, all 6 messages I sent are printed. 

What am I doing wrong?

-- 
View this message in context: 
http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22735051.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to