<br>On 18 September 2010 17:19, Matt Young <span dir="ltr">&lt;<a href="mailto:solid@youngdev.net">solid@youngdev.net</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

        ksession.execute(document);<br></blockquote><div><br>I suppose this inserts a single EventRulesDocument object.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
Here is the rule:<br>
<br>
package sample1<br>
<br>
import sample1.bean.EventRulesDocument;<br>
import sample1.bean.Transaction;<br>
import java.util.Date;<br>
<br>
rule &quot;Standard processing rule&quot;<br>
<br>
    when<br>
          $doc : EventRulesDocument(<br>
            ruleRun == false &amp;&amp;  # &lt;&lt;&lt; Wolfgang<br>
            event != null &amp;&amp; event.eventType.eventCode == &quot;testevent&quot; )<br>
    then<br>
<br>
       Transaction t = new Transaction();<br>
        t.setEvent($doc.getEvent());<br>
        t.setCategory($doc.getEvent().getEventType().getEventCode());<br>
        t.setTransactionAmount($doc.getEvent().getEventAmount());<br>
         t.setCreateTs(new Date());<br>
         t.setUsername($doc.getEvent().getCreateUsername());<br>
<br>
        modify( $doc ) {setRuleRun(true)};   # Wolfgang &lt;&lt;&lt;&lt;&lt;&lt;<br>
        modify( $doc ) {addSaveTransaction(t)} ;<br></blockquote><div><br>Here it is: You modify the EventRulesDocument, which causes another<br>activation of the same rule. One way of avoiding this is to add the rule <br>
attribute no-loop true; another one is what you&#39;ve done.<br><br>This isn&#39;t going to be your only rule?? This one alone is scant reason to use an RBS.<br><br>fireAllRules( 1 ) isn&#39;t a good remedy, because (normally) a Production System<br>
relies on repeated firings, depending on rules and facts.<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
end<br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Additionally If any code in the world can be executed in the RHS, then<br>
why shouldn&#39;t I just use groovy as my rule language?  At least then, I<br>
can write math like such:<br>
def num1=95;<br>
def num2=90;<br>
def num3=num2/num1;<br>
<br>
and all of the math is done with big decimal objects.  IF there is no<br>
restriction on what can be done in the RHS what is the advantage to<br>
using a rules engine over a general purpose scripting language?</blockquote><div><br>There is a good section in the Drools Expert manual: &quot;Why use a rule engine?&quot;.<br>Don&#39;t do it just to be trendy ;-)<br> </div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">  The<br>
whole purpose for me choosing drools over Groovy eval() was that I<br>
didn&#39;t want to give my users the ability to spawn threads, allocate<br>
massive amounts of memory etc.<br></blockquote><div><br>Seriously now, a Domain Specifiy Language is the maximum corset you can<br>force upon your users. But you&#39;ll have to know <i>all</i> they <i>may </i>do, and all the<br>
conditions.<br><br>-W<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
On 09/18/2010 10:59 AM, Wolfgang Laun wrote:<br>
&gt; On 18 September 2010 16:15, Matt Young &lt;<a href="mailto:solid@youngdev.net">solid@youngdev.net</a><br>
</div><div><div></div><div class="h5">&gt; &lt;mailto:<a href="mailto:solid@youngdev.net">solid@youngdev.net</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt; I just started using drools and this is my first time implementing<br>
&gt; a rules engine.  Everything has been pretty smooth but I have<br>
&gt; some quirks that I am not sure I can live with. 1) for some reason,<br>
&gt; if I execute the Knowlege session against an object, the knowlege<br>
&gt; session never returns.<br>
&gt;<br>
&gt;<br>
&gt;&gt; I don&#39;t understand the term &quot;execute...against an object&quot;. Do you<br>
&gt;&gt; mean that you have just one fact inserted befor you call<br>
&gt;&gt; fireAllRules()?<br>
&gt;<br>
&gt;&gt; But anyway, this call not returning is almost certainly due to a<br>
&gt;&gt; loop in your rules, or have you made sure that they don&#39;t?<br>
&gt;<br>
&gt;<br>
&gt; The only way I can get the ksession to return is to make IF (obj ==<br>
&gt; null) part of the LHS and make modify($input){setObj(&quot;complete&quot;)}<br>
&gt; part of the RHS This seems like a deficiency since I have users<br>
&gt; writing their own rules, I can see them forgetting this<br>
&gt; requirement.<br>
&gt;<br>
&gt;<br>
&gt;&gt; Writing rules is programming, no holds barred :-)<br>
&gt;<br>
&gt;&gt; Look into Domain Specific Languages (DSL) as a cushion for the<br>
&gt;&gt; unwary.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; IS their a way to get the ksession to firerules only once?  If so<br>
&gt; what does that look like?<br>
&gt;<br>
&gt;<br>
&gt;&gt; kSession.fireUntilHalt( 1 );<br>
&gt;<br>
&gt;<br>
&gt; 2) It seems that any code I want can be executed in the RHS.  I<br>
&gt; could literally execute something like the following in the RHS.<br>
&gt;<br>
&gt; byte[] b= new byte[10000000000000]; // Really big memory waste<br>
&gt;<br>
&gt; I also could just start a bunch of threads.<br>
&gt;<br>
&gt; The point is that I am intending to let the users write their own<br>
&gt; rules but I can&#39;t do that if there are no restrictions on how/what<br>
&gt; can be done inside the rules.  Any suggestions?  Are there<br>
&gt; sandboxes or filters I can activate to restrict the RHS?<br>
&gt;<br>
&gt;<br>
&gt;&gt; Again: DSL.<br>
&gt;<br>
&gt;&gt; Also, Rule Templates might be the starting point; it&#39;d depend on<br>
&gt;&gt; what the may be allowed to do.<br>
&gt;<br>
&gt;&gt; And what about good old-fashioned training?!<br>
&gt;<br>
&gt;&gt; -W<br>
&gt;<br>
&gt;<br>
<br>
</div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
<div class="im"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
<br>
</div>&gt; _______________________________________________ rules-users mailing<br>
<div class="im">&gt; list <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
</div>- --<br>
<div class="im">Cheers,<br>
Matt Young<br>
<a href="mailto:solid@youngdev.net">solid@youngdev.net</a><br>
<a href="http://youngdev.net" target="_blank">http://youngdev.net</a><br>
<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.10 (GNU/Linux)<br>
Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org/" target="_blank">http://enigmail.mozdev.org/</a><br>
<br>
</div>iQIcBAEBAgAGBQJMlNibAAoJEO5jycTTPEzc5uUQAJ1ku8gHoMLKVf8Y64llpAIK<br>
n0jKIkUbvs44AKEIq3bv6hM9x1sqskJ8zXqV1FmrJ6FLeILPpqc2El/QVQkY5YVh<br>
xKbFU6FOEhjhR8lcOCLu9Pt7Bxh0eWcdpJsGN/4PAaUDmS4f4UEj1OH5TRdxKWvn<br>
sw4nR3N+KxJKIOSsvW2IXcULdiy3rQm3YYs7GvQmiPbrgLzSYxGhPBsy/W18P75f<br>
xefctOjsuFt89BP3BUjzut3Hu7Q/1bhCETwV0sGg2c7oynbgiRY96/tGCvdVYroM<br>
1h0vcv2zwnxmJcWx0ipzf8Tmwkliy2MY2ITcgIrcZP21FY3AxcvU2SvKgrFj9C+N<br>
68c8PM0m0ZMHB5AKNB+2AeI5/52AP9K9LwLxAZu0EaXpS62E/ZIQ0F7TSGNmZi2o<br>
7bYLl1C7BH2JV9+Zfxy4B0kfOzMeoT+cBscA8YUQ8twmy2QHGQ5CqUdRvlaL1Ktc<br>
WfWFLjsuJm09D+iCS8wg+V4DcqeTH7NMPicodUFeXtxzvsZzmXoXRv+OIYGp2zla<br>
uBuMgQGYMI651RTWWvLN4IyUlbwJPWMg974LcBir1SOogyfdU/2A4s4kPMh2CK4v<br>
X/UCK4J/dX1DYGmrpEUqOkyHiajPqfbA7yed+K+SbfUbNwGvzl6q4gaE2eM+w1pz<br>
bT9rOgr9PFpyiL2EPdut<br>
=UoOJ<br>
<div><div></div><div class="h5">-----END PGP SIGNATURE-----<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>
</div></div></blockquote></div><br>