[rules-users] Time constrained rules

Edson Tirelli tirelli at post.com
Fri Jul 6 14:52:54 EDT 2007


   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


2007/7/6, Jason Vasquez <jason at mugfu.com>:
>
> 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
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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/20070706/bad60857/attachment.html 


More information about the rules-users mailing list