[rules-users] Using Sliding Time Window usage in Drools Fusion v5.0.1

Venkat K nabble-venkatp at sneakemail.com
Thu Feb 25 22:22:39 EST 2010


Dear Edson:

Thank you very much for your reply and I appreciate you taking the time to
do it in such a short time.

1. Let my phrase the following from my understanding from your reply and
infer a couple more points. 

a. The sliding window alone can't be used as a main filter. 
b. In other words what goes inside the brackets( MyEvent(<filters here>) 
can only filter the events. 
c. The sliding window operator results and Event filter results are ORed to
provide the final result.

Example situation:

Event1 9:00:01
Event2 9:00:02
Event3 9:00:03
Event4 9:00:04
Event5 9:00:05

The expression 

$event: MyEvent() over window:time( 2s ) from entry-point "My Stream" 

will mean the following for time 9:00:05:

a1. Pickup event 1 - 5 since there is no filter supplied within MyEvent()"
a2. Pickup event 4-5 since they qualify under sliding window.
a3. Create a union of items from Step a1 + a2 to resulting in Event1-5.

d. Sliding window is mainly suitable to use as part accumulate functions.

I would appreciate your response validating my understanding above. 

Also it would be useful to know Is there another way to achieve what we are
looking for here? Meaning that we simply want to loop over events occurred
during some last x period? I am thinking the following may work (After
inserting/updating the CurrentTime event every second:

declare CurrentTime
    @role( event )
end

declare MyEvent
    @role( event )
    @timestamp(eventDateTime)
end

rule "Rule1"
when
    $now: CurrentTime() from entry-point "My Stream"
    //The following should fetch all events occurred in the last 2 seconds)
    $event: MyEvent(this before[2s, 2s] $now) from entry-point "My Stream"
then
    System.out.println($event.getEventName() + ": Event Occured!!!" +     
$event.getEventDateTime().toString());
end

I greatly appreciate your thoughts as well as others on this.

Thanks again for this great piece of software and you taking the time to
read,

Regards,
Venkat.
-- 
View this message in context: http://n3.nabble.com/Re-Using-Sliding-Time-Window-usage-in-Drools-Fusion-v5-0-1-tp415473p416491.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list