<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Did you inform the engine that testFieldData had changed?&nbsp; You need to either call update(<font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">MyDataObject) from the action of a rule, or if you're outside the engine, update() or asyncUpdate() on the session.&nbsp; Otherwise, as far as the engine is concerned, the value hasn't changed.<br></span></font></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Chris Richmond &lt;crichmond@referentia.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> Rules Users List
 &lt;rules-users@lists.jboss.org&gt;<br><b><span style="font-weight: bold;">Sent:</span></b> Wednesday, September 23, 2009 3:35:46 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [rules-users] persistent java objects in working memory<br></font><br>



 
 

 

<style>
<!--
filtered {margin:1.0in 1.25in 1.0in 1.25in;}

 
 _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}
 
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
        {font-family:Arial;color:navy;}
 _filtered {margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {}
-->
</style>



<div class="Section1">

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Now I am really confused, when I try to set some condition
on the MyDataObject itself like this</span></font></p> 

<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> &nbsp;</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">rule
"Identify Java Objects"</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
lock-on-active</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">when</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
$<u><font color="black"><span style="color: black;">mo</span></font></u> :
MyDataObject($mf:testFieldData &lt; 20);</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
$c : Cycle();</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">then</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
System.err.println("MYOBJECT in system: " + $mo.getID() + " |
" + $mo.getTestFieldData());</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">end </span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> &nbsp;</span></font></p> 

<p class="MsoNormal"><font color="#3366ff" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: rgb(51, 102, 255);"> &nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Then this still fires every single time, even when testFieldData
is over 20….</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> &nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">-Chris</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> &nbsp;</span></font></p> 

<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> &nbsp;</span></font></p> 

<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> &nbsp;</span></font></p> 

<div>

<div class="MsoNormal" style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr tabindex="-1" width="100%" align="center" size="3">

</span></font></div>

<p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; 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> Rules
 Users List<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [rules-users]
persistent java objects in working memory</span></font></p> 

</div>

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> &nbsp;</span></font></p> 

<div>

<div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">You've answered your own
question. :)&nbsp; 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.)&nbsp; 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.&nbsp; 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.&nbsp; Let's call it "Cycle" and give it a count. Then your
rule would look like this:</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">rule
"Identify Java Objects"</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
lock-on-active</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">when</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
$<u><font color="black"><span style="color: black;">mo</span></font></u> :
MyDataObject();</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
$c : Cycle();</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">then</span></font></p> 

<p class="MsoNormal" style=""><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;
System.err.println("MYOBJECT in system: " + $mo.getID() + " | "
+ $mo.getTestFieldData() + " on Cycle " + $c.getCount());</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">end </span></font></p> 

</div>

<div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><br>
When the iteration is over, you would retract the Cycle object.&nbsp; (Only one
Cycle should be in working memory at once, and it's a good idea to have a rule
that enforces that invariant.)&nbsp; You should follow this pattern for any
rule you want to guarantee to fire on each iteration.</span></font></p> 

<div>

<div class="MsoNormal" style="text-align: center;" align="center"><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;">

<hr width="100%" align="center" size="1">

</span></font></div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Chris
Richmond &lt;crichmond@referentia.com&gt;<br>
<b><span style="font-weight: bold;">To:</span></b> Rules
 Users List &lt;rules-users@lists.jboss.org&gt;<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></p> 

<div>

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Hello,</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font></p> 

<p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I am trying to create a set of java
objects, which I insert into the session at startup. &nbsp;Then at regular
timed iterations I want to examine the values of those objects. &nbsp;During
the timer iteration, some fields may have been changed by the primary program.
&nbsp;So I have a rule for now that is just trying to identify that the do
indeed exist on each iteration:</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">rule "Identify Java Objects"</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp; lock-on-active</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">when</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp; $<u><font color="black"><span style="color: black;">mo</span></font></u> : MyDataObject();</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">then</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp; System.err.println("MYOBJECT in
system: " + $mo.getID + " | " + $mo.getTestFieldData);</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">end&nbsp;&nbsp; </span></font></p> 

<p class="MsoNormal"><font face="Courier New" size="2"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; 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.
&nbsp;However the output from this rule only fires on the firet iteration,
after that the rule doesn’t fire. &nbsp;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. &nbsp;&nbsp;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></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Any ideas or what I am doing wrong?</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Thanks,</span></font></p> 

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><br>
Chris</span></font></p> 

</div>

</div>

</div>

</div>

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> &nbsp;</span></font></p> 

</div>

</div></div></div><br>

      </body></html>