Thanks for your email below. I needed to refactor my code somewhat to get this technique to work but it solved the problem that I had.

I was previously using fireAllRules() but I refactored the code to use fireUntilHalt() instead, which required some additional work to make a couple of other supporting features behave properly. I know you don't strictly need to do this, but it needed to be done anyway and it made sense to do it now.

I would have thought it was quite a common scenario where someone wanted to implement business logic such as:

- Something happens
- It is expected that something else will happen within a certain time period of the first thing happening
- If the second thing doesn't happen within the time period, generate an alert

I ran into trouble because my various rules (from my original email) wouldn't fire an alert as expected when I fed in simulated events.

I'm curious as to why you think it's interesting that the four rules below fail to meet my expectation? I suppose it's the fact that I'm a drools newbie and the issue here is probably just my inexperience mapping business logic into drools rules.

daveor

On 15 Feb 2014, at 09:49, laune [via Drools] wrote:

> 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 <[hidden email]> 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
> > [hidden email]
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129p4028131.html
> To unsubscribe from Help with event not found over window query, click here.
> NAML



View this message in context: Re: [rules-users] Help with event not found over window query
Sent from the Drools: User forum mailing list archive at Nabble.com.