<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<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>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">> </SPAN></FONT><FONT
face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">Is that a normal
behavior?</SPAN></FONT></P>
<P class=MsoPlainText><FONT face=Arial color=black 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><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Kris</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=SManukyan@lear.com href="mailto:SManukyan@lear.com">Manukyan,
Sergey</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=rules-users@lists.jboss.org
href="mailto:rules-users@lists.jboss.org">Rules Users List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, September 14, 2007 9:19
PM</DIV>
<DIV style="FONT: 10pt arial"><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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">rule "Increment"</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">
ruleflow-group "Up"</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">
when</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">
$i : Integer(intValue < 10)</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"> then
</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">
System.out.println("INTEGER : " + $i);</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">
retract($i);</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">
insert(new Integer($i.intValue() + 1));</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">end</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"><IMG height=315
src="cid:001e01c7f728$3c8af280$6400a8c0@BORG2" width=250></SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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 face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">Thanks…</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black">-Sergey</SPAN></FONT></P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black"></SPAN></FONT> </P>
<P class=MsoPlainText><FONT face="Courier New" color=black 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>
<HR>
<P></P>_______________________________________________<BR>rules-users mailing
list<BR>rules-users@lists.jboss.org<BR>https://lists.jboss.org/mailman/listinfo/rules-users<BR></BLOCKQUOTE></BODY></HTML>