<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:"Calibri","sans-serif";color:#1F497D">Esteban,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I too have been confused by lock-on-active. 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:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Looking at the documentation, and other examples, I think I can how lock-on-active behaves. From what I gather, it looks like when “init “ rule fires, the
activations for that rule consist of the DataSample() facts (all of them). 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:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Since “Rule 1” depends on DataSample, and it is in the same agenda group as init, “Rule 1” 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:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">What is being blocked by lock-on-active is not the reactivation of the rule. 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:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">This block only holds true on the current focus (agenda-group or ruleflow-group). 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:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> 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> </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 (at least what I understand as) expected results.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </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> </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> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">rule "init"<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"> $d: DataSample()<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">then<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> System.out.println("Setting predefined value");<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> modify($d){<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> addValue(Parameter.PARAM_A, 10.0)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">end<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">rule "Rule 1"<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"> DataSample($v: values[Parameter.PARAM_A] < 20)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">then<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> System.out.println("Rule 1: "+$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> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">DataSample is a Java class containing a Map<Parameter, Double> 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. <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 "init"; 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 "init". Well, this is not the case. I don't see any activation for "Rule 1".<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 "Rule 1" so I don't see why it
activation after "init" 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> </o:p></p>
</div>
<div>
<p class="MsoNormal">"<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."<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:24.0pt"><o:p> </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"> <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>