<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
_filtered {margin:1.0in 1.25in 1.0in 1.25in;}
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.emailstyle17
        {font-family:Arial;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>But in your example, wouldn’t the rule
still not fire since the when:<o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
$<u><font color=black><span style='color:black'>mo</span></font></u> :
MyDataObject();</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
$c : Cycle();</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Would be satisfied as far as the $c :
cycle() <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> But the $mo : MyDataObject() : would
still not be satisfied would it?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I am writing up a test of this, but I am
confused…why would $mo : MyDataObject() suddenly be satisfied just because $c :
Cycle() is?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><br>
Thanks,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><br>
Chris<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=3 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Greg Barton<br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, September 23,
2009 10:02 AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">Rules
Users List</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [rules-users]
persistent java objects in working memory</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<div>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>You've answered your own
question. :) The rule you've given will only fire when the object is asserted
or modified. (And you have to inform the engine of the modification.) You
have to inform the engine that the object has been modified every cycle. (And
if you want the engine to fire that rule even if the object has not been
modified, you can still inform the engine. All that does is force the
rules to reconsider the object.)<br>
<br>
However, the way I'd do it is to have a new object that is inserted on each
iteration. Let's call it "Cycle" and give it a count. Then your
rule would look like this:<o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>rule
"Identify Java Objects"</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
lock-on-active</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>when</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
$<u><font color=black><span style='color:black'>mo</span></font></u> :
MyDataObject();</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
$c : Cycle();</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>then</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
System.err.println("MYOBJECT in system: " + $mo.getID() + " |
" + $mo.getTestFieldData() + " on Cycle " + $c.getCount());</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>end </span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><br>
When the iteration is over, you would retract the Cycle object. (Only one
Cycle should be in working memory at once, and it's a good idea to have a rule
that enforces that invariant.) You should follow this pattern for any
rule you want to guarantee to fire on each iteration.<o:p></o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
<hr size=1 width="100%" align=center>
</span></font></div>
<p class=MsoNormal style='margin-bottom:12.0pt'><b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> Chris
Richmond <crichmond@referentia.com><br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">Rules
Users List</st1:PersonName> <rules-users@lists.jboss.org><br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, September 23,
2009 2:15:35 PM<br>
<b><span style='font-weight:bold'>Subject:</span></b> [rules-users] persistent
java objects in working memory</span></font><o:p></o:p></p>
<div>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hello,</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>I am trying to create a set of java
objects, which I insert into the session at startup. Then at regular
timed iterations I want to examine the values of those objects. During
the timer iteration, some fields may have been changed by the primary program.
So I have a rule for now that is just trying to identify that the do
indeed exist on each iteration:</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>rule "Identify Java Objects"</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> lock-on-active</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>when</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> $<u><font color=black><span
style='color:black'>mo</span></font></u> : MyDataObject();</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>then</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> System.err.println("MYOBJECT in
system: " + $mo.getID + " | " + $mo.getTestFieldData);</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> </span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>end </span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> </span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>As I said, at startup I insert 3 of these objects into my
session, then every 10 seconds I just want to ensure they are there.
However the output from this rule only fires on the firet iteration,
after that the rule doesn’t fire. I am not retrcating the objects or even
concerning myself with the FactHandle, as I plan to leave them in working
memory and change values on those 3 objects from the main application in each
application loop, then make decisions in the rule engine based on the values of
those 3 objects. However, for now I just nee to find out why the
objects only live for my first loop and call of session.fireAllRules().</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Any ideas or what I am doing wrong?</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Thanks,</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><br>
Chris</span></font><o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
</div>
</body>
</html>