[rules-users] Time constrained rules

2007-07-06 Thread Jason Vasquez

Hi all,

I need a set of rules to fire on time-based criteria.  I have a  
'Clock' object in working memory, along with an unknown number of  
'TestObject's, each of which can report its 'age'.  At some interval,  
I modify the Clock object in working memory, and then fire the  
rules.  As a start (which I'm certain shouldn't work anyway), I'm  
playing around with a rule like this:


rule remove objects older than 2 seconds
when
Clock()
$to : TestObject( ageInMillis  2000 )
then
	System.out.println(new java.util.Date() +  = Retracting  +  
$to);

retract($to);
end

It appears that the RHS is never executed, presumably because  
TestObjects were not modified.  (I'm new to JBossRules, so I'm  
unclear on that )


Alternatively, I could just remove the Clock() constraint and iterate  
an external collection of TestObject's, marking each object as  
modified.  Just looking for the best way here...


Thanks,
-jason

smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Time constrained rules

2007-07-06 Thread Jason Vasquez

Thanks Edison, that will do the trick.


On Jul 6, 2007, at 2:52 PM, Edson Tirelli wrote:



   Jason,

   Yes, the engine does not see any change in TestObject until you  
call update() for it.

   In your case, I would play that a bit different:

rule remove objects older than 2 seconds
when
Clock( $cur : currentTime )
$to : TestObject( creationTime  ( $cur - 2000 ) )
then
System.out.println(new java.util.Date() +  =  
Retracting  +

$to);
retract($to);
end

   This way you only need to update your clock object and not your  
testObjects.


   []s
   Edson




smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users