Still trying to get sliding windows to work (basing my code off of the
Eclipse supplied "Hello World" example). I don't think I fully understand
how it works yet so I'm trying to simplify things even further by writing a
simple rule that is meant to say:
if (current_message = "Hello" AND exists( goodbye_message within
sliding_window(3 seconds) ))
then print("There was a GOODBYE message before the HELLO message." )
In other words: This rule should fire if the current Hello World message was
preceeded within 3 seconds by a goodbye message.
---------------------------------------------------------------------------------------------------
I wrote a new rule for this:
declare Message
@role( event )
end
rule "Goodbye before Hello World"
when
Message( status == Message.HELLO )
exists( Message( status == Message.GOODBYE ) over window:time( 3s ) )
then
System.out.println( "There was a GOODBYE message before the HELLO
message." );
end
---------------------------------------------------------------------------------------------------
To send the messages: (ksession is a StatefulKnowledgeSession)
...
ksession.insert(goodbye_message);
ksession.fireAllRules();
Thread.sleep(5000);
ksession.insert(hello_message);
ksession.fireAllRules();
...
---------------------------------------------------------------------------------------------------
I expect to get nothing back since I sent the Hello message 5 seconds after
the goodbye message (outside the sliding window of 3 seconds). But, for some
reason the rule fires and I get one:
"There was a GOODBYE message before the HELLO message."
Any help would be greatly appreciated.
Thanks!
--
View this message in context:
http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22...
Sent from the drools - user mailing list archive at
Nabble.com.