<div dir="ltr"><br>&nbsp;&nbsp; Ok, your case seems clearly a case where you need either a StatefulSession or your application needs to send previous readings to drools.<br>&nbsp;&nbsp; If you are using a StatefulSession AND you always use the same SystemInfo object (just use update on it), you could use &quot;duration&quot; on your rule:<br>
<br>rule &quot;Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds&quot;<br>&nbsp;&nbsp; duration 60000<br>when <br>&nbsp;&nbsp;&nbsp; SystemInfo (idle &gt;= 70) &nbsp;//Idle continuously for 60 seconds<br><div>then<br>&nbsp; &nbsp; // start new process<br>
end<br><br>&nbsp;&nbsp; Using StatelessSession, you must have an update rule for your object<br><br>rule &quot;System_is_70%_Idle&quot;<br>&nbsp;&nbsp;&nbsp; salience 10<br>when <br>
&nbsp;&nbsp;&nbsp; $si : SystemInfo (idle &gt;= 70)&nbsp; <br>
then<br>&nbsp;&nbsp;&nbsp; $si.setIdleCounter( $si.getIdleCounter() + 1 );<br>end<br>
<br></div>rule &quot;Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds&quot;<br>
when <br>
&nbsp;&nbsp;&nbsp; SystemInfo( idleCounter &gt;= 12)&nbsp; <br>
then<br>
&nbsp; &nbsp; // start new process<br>
end<br>
<br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">2008/8/19 ganesh.p <span dir="ltr">&lt;<a href="mailto:ganesh_patkar@hotmail.com">ganesh_patkar@hotmail.com</a>&gt;</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>
 &nbsp; &nbsp; &nbsp; &nbsp;private double idle; //System idle percentage<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;public void setIdle(double idle) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this.idle = idle;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;public double getIdle() {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return this.idle;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<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 &quot;Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds&quot;<br>
<br>
when SystemInfo (idle &gt;= 70) &nbsp;//Idle continuously for 60 seconds<br>
then<br>
 &nbsp;// 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 &quot;idle &gt;= 70&quot;.<br>
Even if a single SystemInfo doesn&#39;t match this condition then this rule<br>
shouldn&#39;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>