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

2014-02-19 Thread daveor
On 18 Feb 2014, at 18:38, laune [via Drools] wrote:

[snip]
> 
> > 
> > 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. 
> 
> The word is "illuminative" rather than "interesting". Take this one: 
> 
> $e1: Event($location: properties["location"] && ...) 
> not Event(, this after $e1) 
> 
> The $e1 Event is here, Time is Now. It's most certainly true that 
> nothing is here after Now! - And the next one: 
> 
> $e1: Event($location: properties["location"] && ...) 
> not Event(, this after[0, 1m] $e1) 
> 
> Again, Event $e1 is here, Time is Now, and nothing is here after Now. 
> The operator does not instruct the Engine to wait! 
> 

Yes, I had imagined something like that was the case.

My original reasoning was the following; 

At the moment when the $e1 event arrives, time is Now and it is true that there 
is no second event. 
However, there is no way for the engine to know at Time=Now whether or not the 
second event is going to arrive within the required time period (this 
after[0,1m] $e1)
Surely, the engine needs to wait until (at least) Time=Now+1m before firing the 
rule, at least in the second case, because it is not possible to establish the 
truth or falsehood of the second criterion until 1m has past since the first 
event arrived because the second event might arrive, right?

Well, that's what I thought at least!

daveor



--
View this message in context: 
http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129p4028190.html
Sent from the Drools: User forum mailing list archive at Nabble.com.___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

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

2014-02-18 Thread daveor
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 e

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

2014-02-14 Thread daveor
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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users