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.
<br/><br/>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.
<br/><br/>I would have thought it was quite a common scenario where someone wanted to implement business logic such as:
<br/><br/>- Something happens
<br/>- It is expected that something else will happen within a certain time period of the first thing happening
<br/>- If the second thing doesn't happen within the time period, generate an alert
<br/><br/>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.
<br/><br/>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.
<br/><br/>daveor
<br/><br/>On 15 Feb 2014, at 09:49, laune [via Drools] wrote:
<br/><div class='shrinkable-quote'><br/>> It would be interesting to discuss why each of these four rules fails to
<br/>> meet you expectation. Mostly it's due to the engine not evaluating
<br/>> exactly one minute after the "certain event" arrives.
<br/>>
<br/>> The following rule fires 1 minute after the evaluation of the arrival
<br/>> of an Event according to constraints and when no second Event
<br/>> (according to constraints not shown) has arrived since then.
<br/>>
<br/>> rule "Something Else" dialect "mvel"
<br/>> timer ( int: 1m )
<br/>> when
<br/>> $e1: Event($location: properties["location"] && ...)
<br/>> not Event(..., this after $e1)
<br/>> then
<br/>> ...
<br/>> end
<br/>>
<br/>> -W
<br/>>
<br/>> On 14/02/2014, daveor <[hidden email]> wrote:
<br/>>
<br/>> > Hi there,
<br/>> >
<br/>> > I'm a drools newbie and I wonder if someone could help me. I'm using drools
<br/>> > 6.0.1 and I'm trying to write a rule that fires when:
<br/>> >
<br/>> > 1) a certain event is seen and
<br/>> > 2) a second event is not seen within a certain period of time (1 minute in
<br/>> > the examples below) after the first event is seen
<br/>> >
<br/>> > I have tried the following LHS patterns:
<br/>> >
<br/>> > rule "Something" dialect "mvel"
<br/>> > when
<br/>> > $e1: Event($location: properties["location"] && ...)
<br/>> > not Event(...., this after $e1)
<br/>> > then
<br/>> > //do stuff
<br/>> > end
<br/>> >
<br/>> > rule "Something" dialect "mvel"
<br/>> > when
<br/>> > $e1: Event($location: properties["location"] && ...)
<br/>> > not Event(...., this after[0, 1m] $e1)
<br/>> > then
<br/>> > //do stuff
<br/>> > end
<br/>> >
<br/>> > rule "Something" dialect "mvel"
<br/>> > when
<br/>> > $e1: Event($location: properties["location"] && ...)
<br/>> > List (size == 0) from collect (Event(..., this after $e1) over
<br/>> > window:time(1m))
<br/>> > then
<br/>> > //do stuff
<br/>> > end
<br/>> >
<br/>> >
<br/>> > rule "Something" dialect "mvel"
<br/>> > when
<br/>> > $e1: Event($location: properties["location"] && ...)
<br/>> > List (size == 0) from collect (Event(...) over window:time(1m))
<br/>> > then
<br/>> > //do stuff
<br/>> > end
<br/>> >
<br/>> > The unwanted behaviours are as follows:
<br/>> >
<br/>> > In the first case, the rule fires immediately after the first event is
<br/>> > inserted.
<br/>> > In the second case, the rule fails to fire if the second event is seen (as
<br/>> > expected) but the rule does not fire if the second event is not seen within
<br/>> > 1 minute.
<br/>> > In the third and fourth cases, the rule fires immediately after the first
<br/>> > event is inserted.
<br/>> >
<br/>> > Event is a java class with a hash map of properties, defined with the
<br/>> > following metadata:
<br/>> >
<br/>> > declare Event
<br/>> > @role(event)
<br/>> > end
<br/>> >
<br/>> > I would really appreciate if someone could help me out here.
<br/>> >
<br/>> > Thanks and let me know if you need any more info.
<br/>> >
<br/>> > Dave
<br/>> >
<br/>> >
<br/>> >
<br/>> >
<br/>> > --
<br/>> > View this message in context:
<br/>> > <a href="http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129.html" target="_top" rel="nofollow" link="external">http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129.html</a><br/>> > Sent from the Drools: User forum mailing list archive at Nabble.com.
<br/>> > _______________________________________________
<br/>> > rules-users mailing list
<br/>> > [hidden email]
<br/>> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_top" rel="nofollow" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br/>> >
<br/>> _______________________________________________
<br/>> rules-users mailing list
<br/>> [hidden email]
<br/>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_top" rel="nofollow" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br/>>
<br/>>
<br/>> If you reply to this email, your message will be added to the discussion below:
<br/>> <a href="http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129p4028131.html" target="_top" rel="nofollow" link="external">http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129p4028131.html</a><br/>> To unsubscribe from Help with event not found over window query, click here.
<br/>> NAML
</div><br/>
        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129p4028171.html">Re: [rules-users] Help with event not found over window query</a><br/>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools: User forum mailing list archive</a> at Nabble.com.<br/>