[rules-users] Fire rule only when all the fact objects sent during a specific period match the WHEN part
Edson Tirelli
tirelli at post.com
Tue Aug 19 08:51:14 EDT 2008
Ok, your case seems clearly a case where you need either a
StatefulSession or your application needs to send previous readings to
drools.
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:
rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
duration 60000
when
SystemInfo (idle >= 70) //Idle continuously for 60 seconds
then
// start new process
end
Using StatelessSession, you must have an update rule for your object
rule "System_is_70%_Idle"
salience 10
when
$si : SystemInfo (idle >= 70)
then
$si.setIdleCounter( $si.getIdleCounter() + 1 );
end
rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
when
SystemInfo( idleCounter >= 12)
then
// start new process
end
[]s
Edson
2008/8/19 ganesh.p <ganesh_patkar at hotmail.com>
>
> I need to create a rule with following requirements:
>
> There is a fact class called SystemInfo which contains idle information of
> a
> sytem
>
> public class SystemInfo {
> private double idle; //System idle percentage
>
> public void setIdle(double idle) {
> this.idle = idle;
> }
>
> public double getIdle() {
> return this.idle;
> }
> }
>
>
> The SystemInfo objects are continuously sent to DROOLS (StatelessSession)
> with 5 second delay.
>
> I need to create a rule
>
>
> rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
>
> when SystemInfo (idle >= 70) //Idle continuously for 60 seconds
> then
> // start new process
>
> end
>
>
> I need to fire this rule only if all the 12 SystemInfo objects which are
> sent with 5 seconds delay for 60 seconds, match the condition "idle >= 70".
> Even if a single SystemInfo doesn't match this condition then this rule
> shouldn't be fired.
>
> I am using DROOLS 4.0. Please help me in implementing the WHEN condition.
>
> Thanks
> -Ganesh
> --
> View this message in context:
> http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19029247.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080819/0229c3db/attachment.html
More information about the rules-users
mailing list