[rules-users] Help with event not found over window query

Wolfgang Laun wolfgang.laun at gmail.com
Sat Feb 15 04:48:11 EST 2014


It would be interesting to discuss why each of these four rules fails to
meet you expectation. Mostly it's due to the engine not evaluating
exactly one minute after the "certain event" arrives.

The following rule fires 1 minute after the evaluation of the arrival
of an Event according to constraints and when no second Event
(according to constraints not shown) has arrived since then.

rule "Something Else" dialect "mvel"
    timer ( int: 1m )
when
    $e1: Event($location: properties["location"] && ...)
    not Event(..., this after $e1)
then
   ...
end

-W

On 14/02/2014, daveor <dump at daveor.com> wrote:
> Hi there,
>
> I'm a drools newbie and I wonder if someone could help me. I'm using drools
> 6.0.1 and I'm trying to write a rule that fires when:
>
> 1) a certain event is seen and
> 2) a second event is not seen within a certain period of time (1 minute in
> the examples below) after the first event is seen
>
> I have tried the following LHS patterns:
>
> rule "Something" dialect "mvel"
> when
>     $e1: Event($location: properties["location"] && ...)
>     not Event(...., this after $e1)
> then
>     //do stuff
> end
>
> rule "Something" dialect "mvel"
> when
>     $e1: Event($location: properties["location"] && ...)
>     not Event(...., this after[0, 1m] $e1)
> then
>     //do stuff
> end
>
> rule "Something" dialect "mvel"
> when
>     $e1: Event($location: properties["location"] && ...)
>     List (size == 0) from collect (Event(..., this after $e1) over
> window:time(1m))
> then
>     //do stuff
> end
>
>
> rule "Something" dialect "mvel"
> when
>     $e1: Event($location: properties["location"] && ...)
>     List (size == 0) from collect (Event(...) over window:time(1m))
> then
>     //do stuff
> end
>
> The unwanted behaviours are as follows:
>
> In the first case, the rule fires immediately after the first event is
> inserted.
> In the second case, the rule fails to fire if the second event is seen (as
> expected) but the rule does not fire if the second event is not seen within
> 1 minute.
> In the third and fourth cases, the rule fires immediately after the first
> event is inserted.
>
> Event is a java class with a hash map of properties, defined with the
> following metadata:
>
> declare Event
> 	@role(event)
> end
>
> I would really appreciate if someone could help me out here.
>
> Thanks and let me know if you need any more info.
>
> Dave
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list