Thanks for your clarifications and thoughts.<div>My misunderstanding was because I always thought that lock-on-active meant lock-on-RULE-active. Something like lock after the first activation and do not unlock until the agenda group is changed.</div>

<div>The real meaning is lock-on-AGENDA_GROUP-active. Meaning: do not create activations of this rule (no matter if using update(), modify(), insert() or retract()) if the agenda group where it belongs is active.</div><div>

<br></div><div>Best Regards!</div><div class="gmail_extra"><br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>


<br><br><div class="gmail_quote">On Thu, Nov 15, 2012 at 7:54 AM, Mattias Nilsson Grip <span dir="ltr">&lt;<a href="mailto:mattias.nilsson.grip@redpill-linpro.com" target="_blank">mattias.nilsson.grip@redpill-linpro.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Armand/Esteban,<br>
<br>
I had a look at source code ( org.drools.common.DefaultAgenda.createActivation(...) ) and as far as I can tell it should not matter if the rules match on the same facts or not. I interpret the source code like this:<br>
<br>
&quot;While an agenda group or rule flow group is active, any rules within that group with lock-on-active set to true are prevented from creating new activations&quot;<br>
<br>
I.e. the rule &quot;Rule 1&quot; cannot create an activation since its agenda group MAIN is already active when its conditions are fulfilled.<br>
<br>
Regards,<br>
Mattias<br>
<div><div class="h5"><br>
----- Original Message -----<br>
From: &quot;Armand Welsh&quot; &lt;<a href="mailto:AWelsh@statestreet.com">AWelsh@statestreet.com</a>&gt;<br>
To: &quot;Rules Users List&quot; &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
Sent: Wednesday, 14 November, 2012 11:04:36 PM<br>
Subject: Re: [rules-users] lock-on-active clarification needed<br>
<br>
Esteban,<br>
<br>
I too have been confused by lock-on-active. Only after reading the definition many times, have I come to the following conclusion:<br>
<br>
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.<br>


<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Esteban Aliverti<br>


Sent: Wednesday, November 14, 2012 3:41 AM<br>
To: Rules Users List<br>
Subject: [rules-users] lock-on-active clarification needed<br>
<br>
Hi all,<br>
<br>
I&#39;m dealing with a set of rules having the lock-on-active attribute and I&#39;m not getting the (at least what I understand as) expected results.<br>
<br>
I&#39;ve created an isolated JUnit test. I&#39;m attaching it to this email.<br>
<br>
Basically, I have 2 rules:<br>
<br>
rule &quot;init&quot;<br>
<br>
lock-on-active true<br>
<br>
when<br>
$d: DataSample()<br>
then<br>
System.out.println(&quot;Setting predefined value&quot;);<br>
modify($d){<br>
addValue(Parameter.PARAM_A, 10.0)<br>
}<br>
end<br>
<br>
rule &quot;Rule 1&quot;<br>
lock-on-active true<br>
when<br>
DataSample($v: values[Parameter.PARAM_A] &lt; 20)<br>
then<br>
System.out.println(&quot;Rule 1: &quot;+$v);<br>
end<br>
<br>
DataSample is a Java class containing a Map&lt;Parameter, Double&gt; where Parameter is an enum.<br>
<br>
In the test I&#39;m creating a ksession and inserting an empty DataSample object.<br>
<br>
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.<br>
<br>
Now, after I call fireAllRules() I expect that &#39;Rule 1&#39; becomes active because of the modification of the fact in &quot;init&quot;. Well, this is not the case. I don&#39;t see any activation for &quot;Rule 1&quot;.<br>


<br>
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&#39;t see why it activation after &quot;init&quot; is executed should be prevented.<br>


<br>
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&#39;t get any hint:<br>
<br>
&quot;<br>
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 will not be activated any more ; 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&#39;s ideal for calculation rules where you have a number of rules that modify a fact and you don&#39;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;<br>


<br>
Best Regards,<br>
<br>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
<br>
Esteban Aliverti<br>
- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
</div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>