<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
ah yes I missed this. use the rule attribute "lock-on-active" to stop
this behaviour, it stops a rule re-activating while the ruleflowgroup
is active.<br>
<br>
Mark<br>
Kris Verlaenen wrote:
<blockquote cite="mid:002301c7f728$3d0e0530$6400a8c0@BORG2" type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.6000.16525" name="GENERATOR">
<style>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 77.95pt 1.0in 77.95pt; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
P.MsoPlainText {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Courier New"
}
LI.MsoPlainText {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Courier New"
}
DIV.MsoPlainText {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Courier New"
}
DIV.Section1 {
        page: Section1
}
</style>
<div><font face="Arial" size="2">
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">> Now my
understanding is that It should execute rule “Increment” 5 times…. But
instead it does it 10 times…</span></font></p>
<p class="MsoPlainText"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; color: black;">> </span></font><font
color="black" face="Courier New" size="2"><span
style="font-size: 10pt; color: black;">Is that a normal behavior?</span></font></p>
<p class="MsoPlainText"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; color: black;"></span></font> </p>
Well, actually, this is expected behaviour, let me try to clarify.</font></div>
<div> </div>
<div><font face="Arial" size="2">Whenever a RuleSet node, like your
"Up" node, is activated, it starts executing activations that are part
of that ruleflow-group until no more activations can be found. Then
the node will finish and the flow will continue with the next node.
The problem is that your node, as it is implemented now, automatically
increments your Integer 10 times in a row (you can easily test this by
just executing this rule without a ruleflow present). The reason is,
once you removed your old integer and inserted a new one, this new
Integer will match the same rule again, so your "Up" node will not just
continue after one increment, but will increment 10 times (until the
integer does not match the <10 pattern of your rule anymore) and
then continue to the end.</font></div>
<div> </div>
<div><font face="Arial" size="2">If I understand what you are trying
to do, you should try to make sure that your "Up" rule only increments
once. The best way I could think of right now is adding this at the
end of your rule, </font></div>
<div> </div>
<div><font face="Arial" size="2">
<div><font face="Arial" size="2"> <font size="2">drools.getWorkingMemory().getAgenda().deactivateRuleFlowGroup(</font><font
color="#008000" size="2">"Up"</font><font size="2">);</font></font></div>
<div> </div>
which will automatically deactivate your ruleflow-group and continue
with your execution. But you'll have to use the latest svn code
(or 4.0.2 which is released next week), as I found a small problem
which would prevent you from doing this in 4.0.1 (.</font></div>
<div> </div>
<div><font face="Arial" size="2">[Note: While using the no-loop rule
attribute for your rule might solve the problem of reactivation of the
same rule after an update outside the context of ruleflow, in this
case, it will not be sufficient as it will not only block the
reactivation of your rule for now but also for all future executions of
your "Up" node in your flow, leading to an infinite loop.]</font></div>
<div> </div>
<div><font face="Arial" size="2">When you are trying to implement a
loop, you should also put your join first, and your split at the end.
That way, you will decide what you want to do (in your split) every
time AFTER your rule set has been executed. You can then decide to
either go back (to the join in the beginning) or end. </font></div>
<div> </div>
<div><font face="Arial" size="2">Also note that doing something like
this will become much easier once we add support for ruleflow
variables, as you would simply define a variable counter and you would
be able to define an action like counter++, and use your
ruleflow-groups for executing "real" rules.</font></div>
<div> </div>
<div><font face="Arial" size="2">Kris</font></div>
<div> </div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a moz-do-not-send="true" title="SManukyan@lear.com"
href="mailto:SManukyan@lear.com">Manukyan, Sergey</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a moz-do-not-send="true" title="rules-users@lists.jboss.org"
href="mailto:rules-users@lists.jboss.org">Rules Users List</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Friday, September 14, 2007 9:19 PM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
[rules-users] rule flow</div>
<div><br>
</div>
<div class="Section1">
<p class="MsoPlainText"><font face="Courier New" size="2"><span
style="font-size: 10pt;">Folks,</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">Using 4.0.1.
Trying to do use rule flow to manage the execution of rules. As I
understood in Split node with type XOR I can set conditions for each
destination that are executed against facts in working memory. </span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">Let's consider I
have a rule that executes every time it finds Integer object in memory
and increments it.</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">rule "Increment"</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">
ruleflow-group "Up"</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"> when</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"> $i :
Integer(intValue < 10)</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"> then </span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">
System.out.println("INTEGER : " + $i);</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">
retract($i);</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">
insert(new Integer($i.intValue() + 1));</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">end</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">Now, I have the
following rule flow in place: </span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"><img
src="cid:part1.06040703.04030704@codehaus.org" height="315" width="250"></span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">The Split to Up
arrow has constraint : Integer(intValue < 5)</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">And initially I
am inserting this fact : insert (new Integer(0))</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">Now my
understanding is that It should execute rule “Increment” 5 times…. But
instead it does it 10 times…</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">Is that a normal
behavior? Why cannot Split understand that only when there is an
Integer(intValue < 5) only then execute rule with ruleflow-group "Up"</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">Thanks…</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;">-Sergey</span></font></p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
<p class="MsoPlainText"><font color="black" face="Courier New"
size="2"><span style="font-size: 10pt; color: black;"></span></font> </p>
</div>
<table>
<tbody>
<tr>
<td bgcolor="#ffffff"><font color="#000000">**********************<br>
** LEGAL DISCLAIMER **<br>
**********************<br>
<br>
This E-mail message and any attachments may contain <br>
legally privileged, confidential or proprietary <br>
information. If you are not the intended recipient(s),<br>
or the employee or agent responsible for delivery of <br>
this message to the intended recipient(s), you are <br>
hereby notified that any dissemination, distribution <br>
or copying of this E-mail message is strictly <br>
prohibited. If you have received this message in <br>
error, please immediately notify the sender and <br>
delete this E-mail message from your computer.<br>
</font></td>
</tr>
</tbody>
</table>
<p> </p>
<hr> _______________________________________________<br>
rules-users mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</body>
</html>