<div dir="ltr"><br> Ok, your case seems clearly a case where you need either a StatefulSession or your application needs to send previous readings to drools.<br> If you are using a StatefulSession AND you always use the same SystemInfo object (just use update on it), you could use "duration" on your rule:<br>
<br>rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"<br> duration 60000<br>when <br> SystemInfo (idle >= 70) //Idle continuously for 60 seconds<br><div>then<br> // start new process<br>
end<br><br> Using StatelessSession, you must have an update rule for your object<br><br>rule "System_is_70%_Idle"<br> salience 10<br>when <br>
$si : SystemInfo (idle >= 70) <br>
then<br> $si.setIdleCounter( $si.getIdleCounter() + 1 );<br>end<br>
<br></div>rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"<br>
when <br>
SystemInfo( idleCounter >= 12) <br>
then<br>
// start new process<br>
end<br>
<br> []s<br> Edson<br><br><div class="gmail_quote">2008/8/19 ganesh.p <span dir="ltr"><<a href="mailto:ganesh_patkar@hotmail.com">ganesh_patkar@hotmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I need to create a rule with following requirements:<br>
<br>
There is a fact class called SystemInfo which contains idle information of a<br>
sytem<br>
<br>
public class SystemInfo {<br>
private double idle; //System idle percentage<br>
<br>
public void setIdle(double idle) {<br>
this.idle = idle;<br>
}<br>
<br>
public double getIdle() {<br>
return this.idle;<br>
}<br>
}<br>
<br>
<br>
The SystemInfo objects are continuously sent to DROOLS (StatelessSession)<br>
with 5 second delay.<br>
<br>
I need to create a rule<br>
<br>
<br>
rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"<br>
<br>
when SystemInfo (idle >= 70) //Idle continuously for 60 seconds<br>
then<br>
// start new process<br>
<br>
end<br>
<br>
<br>
I need to fire this rule only if all the 12 SystemInfo objects which are<br>
sent with 5 seconds delay for 60 seconds, match the condition "idle >= 70".<br>
Even if a single SystemInfo doesn't match this condition then this rule<br>
shouldn't be fired.<br>
<br>
I am using DROOLS 4.0. Please help me in implementing the WHEN condition.<br>
<br>
Thanks<br>
-Ganesh<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19029247.html" target="_blank">http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19029247.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>