<br>On 18 September 2010 17:19, Matt Young <span dir="ltr"><<a href="mailto:solid@youngdev.net">solid@youngdev.net</a>></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 "Standard processing rule"<br>
<br>
when<br>
$doc : EventRulesDocument(<br>
ruleRun == false && # <<< Wolfgang<br>
event != null && event.eventType.eventCode == "testevent" )<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 <<<<<<<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've done.<br><br>This isn't going to be your only rule?? This one alone is scant reason to use an RBS.<br><br>fireAllRules( 1 ) isn'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'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: "Why use a rule engine?".<br>Don'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'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'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>
> On 18 September 2010 16:15, Matt Young <<a href="mailto:solid@youngdev.net">solid@youngdev.net</a><br>
</div><div><div></div><div class="h5">> <mailto:<a href="mailto:solid@youngdev.net">solid@youngdev.net</a>>> wrote:<br>
><br>
> I just started using drools and this is my first time implementing<br>
> a rules engine. Everything has been pretty smooth but I have<br>
> some quirks that I am not sure I can live with. 1) for some reason,<br>
> if I execute the Knowlege session against an object, the knowlege<br>
> session never returns.<br>
><br>
><br>
>> I don't understand the term "execute...against an object". Do you<br>
>> mean that you have just one fact inserted befor you call<br>
>> fireAllRules()?<br>
><br>
>> But anyway, this call not returning is almost certainly due to a<br>
>> loop in your rules, or have you made sure that they don't?<br>
><br>
><br>
> The only way I can get the ksession to return is to make IF (obj ==<br>
> null) part of the LHS and make modify($input){setObj("complete")}<br>
> part of the RHS This seems like a deficiency since I have users<br>
> writing their own rules, I can see them forgetting this<br>
> requirement.<br>
><br>
><br>
>> Writing rules is programming, no holds barred :-)<br>
><br>
>> Look into Domain Specific Languages (DSL) as a cushion for the<br>
>> unwary.<br>
><br>
><br>
><br>
> IS their a way to get the ksession to firerules only once? If so<br>
> what does that look like?<br>
><br>
><br>
>> kSession.fireUntilHalt( 1 );<br>
><br>
><br>
> 2) It seems that any code I want can be executed in the RHS. I<br>
> could literally execute something like the following in the RHS.<br>
><br>
> byte[] b= new byte[10000000000000]; // Really big memory waste<br>
><br>
> I also could just start a bunch of threads.<br>
><br>
> The point is that I am intending to let the users write their own<br>
> rules but I can't do that if there are no restrictions on how/what<br>
> can be done inside the rules. Any suggestions? Are there<br>
> sandboxes or filters I can activate to restrict the RHS?<br>
><br>
><br>
>> Again: DSL.<br>
><br>
>> Also, Rule Templates might be the starting point; it'd depend on<br>
>> what the may be allowed to do.<br>
><br>
>> And what about good old-fashioned training?!<br>
><br>
>> -W<br>
><br>
><br>
<br>
</div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a> <mailto:<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><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>> _______________________________________________ rules-users mailing<br>
<div class="im">> list <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>
</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>