<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:m="http://schemas.microsoft.com/office/2004/12/omml" 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 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@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","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Esteban,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">I too have been confused by lock-on-active.&nbsp; Only after reading the definition many times, have I come to the following conclusion:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Looking at the documentation, and other examples, I think I can how lock-on-active behaves.&nbsp; &nbsp;From what I gather, it looks like when &#8220;init &#8220; rule fires, the
 activations for that rule consist of the DataSample() facts (all of them).&nbsp; You then modify the fact, but at the same time, the lock-on-active blocks any further activations from occur as a result of modifying the DataSample() fact.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Since &#8220;Rule 1&#8221; depends on DataSample, and it is in the same agenda group as init, &#8220;Rule 1&#8221; cannot fire until the agenda group is changed, or the ruleflow-group
 is changed.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">What is being blocked by lock-on-active is not the reactivation of the rule.&nbsp; What is being blocked is the resultant activations as a result of modify the DataSample
 fact.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">This block only holds true on the current focus (agenda-group or ruleflow-group).&nbsp; Think of it as a way of temporarily removing the facts from the knowledge
 tree.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
<b>On Behalf Of </b>Esteban Aliverti<br>
<b>Sent:</b> Wednesday, November 14, 2012 3:41 AM<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> [rules-users] lock-on-active clarification needed<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<div>
<p class="MsoNormal">I'm dealing with a set of rules having the lock-on-active attribute and I'm not getting the&nbsp;(at least what I understand as)&nbsp;expected results.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">I've created an isolated JUnit test. I'm attaching it to this email.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Basically, I have 2 rules:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">rule &quot;init&quot;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">lock-on-active true<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">when<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; $d: DataSample()<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">then<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; System.out.println(&quot;Setting predefined value&quot;);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; modify($d){<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; &nbsp; &nbsp; addValue(Parameter.PARAM_A, 10.0)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">end<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">rule &quot;Rule 1&quot;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">lock-on-active true<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">when<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; DataSample($v: values[Parameter.PARAM_A] &lt; 20)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">then<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; System.out.println(&quot;Rule 1: &quot;&#43;$v);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">end<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">DataSample is a Java class containing a Map&lt;Parameter, Double&gt; where Parameter is an enum.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">In the test I'm creating a ksession and inserting an empty DataSample object.&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I understand that as soon as the object is inserted, both rules are evaluated and the result is going to be an activation of rule &quot;init&quot;; and this is what is actually happening. So far so good.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Now, after I call fireAllRules() I expect that 'Rule 1' becomes active because of the modification of the fact in &quot;init&quot;. Well, this is not the case. I don't see any activation for &quot;Rule 1&quot;.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">My understanding about lock-on-active is that a rule that WAS ACTIVATED is not going to be re-activated until the current agenda group is switched. The odd thing here is that I never had an activation for &quot;Rule 1&quot; so I don't see why it
 activation after &quot;init&quot; is executed should be prevented.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">So my question is: Is my understanding wrong? What is the expected behavior of lock-on-active in this situation? I read the documentation but I couldn't get any hint:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">&quot;<o:p></o:p></p>
<p style="margin-left:.5in;display:inline!important">Whenever a ruleflow-group becomes active or an agenda-group receives the focus, any rule within that group that has lock-on-active set to true<b> will not be activated any more</b>; irrespective of the origin
 of the update, the activation of a matching rule is discarded. This is a stronger version of no-loop, because the change could now be caused not only by the rule itself. It's ideal for calculation rules where you have a number of rules that modify a fact and
 you don't want any rule re-matching and firing again. Only when the ruleflow-group is no longer active or the agenda-group loses the focus those rules with lock-on-active set to true become eligible again for their activations to be placed onto the agenda.&quot;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:24.0pt"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:24.0pt">Best Regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:24.0pt">&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:24.0pt"><br>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
<br>
Esteban Aliverti<br>
- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><o:p></o:p></p>
</div>
</div>
</body>
</html>