[rules-users] Retraction of facts based on time - any ideas please?

Wolfgang Laun wolfgang.laun at gmail.com
Sun May 3 02:10:54 EDT 2009


Create a single fact, say Clock, with a field time. Assuming that this value
is updated once in a while, depending on the precision with which your time
supervision should work, you may then write rules such as

rule extract
when
     Clock( $time : time )
     e1 : Event (code == "LOGON", status == "ACTIVE",
            $ts: longTimeStamp < ($time - 100) )
then
     retract( e1 );
end

2009/4/30 <rsundaar at aretus.biz>

>
> I have a need to "expire" some facts based on time. In other words, if an
> event occurs some time and if sufficient time has gone by, the fact should
> become inonsequential and be retracted. Here is my simple rule to do this:
>
> **
> *rule*"Retract expired facts"
>  *dialect*"mvel"
>  // salience -5
>  *when*
>  e1 : Event (code == "LOGON", status == "ACTIVE")
> *eval* ((getCurrentTimeStamp ()- e1.getLongTimeStamp()) > 100)
> *then*
> System.out.println( "Retracting expired event with Timestamp: " +
> e1.longTimeStamp );
> *retract* (e1);
>   *end*
>
> This does not seem to work because the "eval" method does not evaluate the
> rule every cycle. And, there is no other change to the fact (event) to force
> the rule to re-evaluate the fact. Is there a way to make "eval" in the LHS
> evaluate every cycle? Is there any other method?
>
> I would greatly appreciate any ideas.
>
> Thanks,
>
> Ravi.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090503/ca7b7368/attachment.html 


More information about the rules-users mailing list