Yes, that is standard approach. <br> Just don't share the same working memory among multiple threads (seems you are not doing that, so just reinforcing). The rule base may be shared, no problem.<br><br> []s<br> Edson
<br><br><br><div><span class="gmail_quote">2007/3/28, Jones, Alan R <<a href="mailto:alan.r.jones@boeing.com">alan.r.jones@boeing.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">This is actually very close to the approach I am going to
try:</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"> The caching is replaced by an object
representing/encapsulating a given rulebase created as a new/separate thread. A
reference to said object is registered (cached?). When a Fact comes along, the
appropriate rulebase/object is looked up and the fact is fed to it (the object
has a method that takes the fact and asserts it into a new working memory),
then the object fires the rule. Does this approach make
sense?</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Thanks,</font></span><br><br></div>
<p><span lang="en-us"><font face="Arial" size="2">aj</font></span> </p>
<div><font color="#0000ff" face="Arial" size="2"></font> </div><br>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma" size="2"><b>From:</b> Edson Tirelli [mailto:<a href="mailto:tirelli@post.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tirelli@post.com</a>]
<br><b>Sent:</b> Wednesday, March 28, 2007 11:03 AM<br><b>To:</b> Rules Users
List<br><b>Subject:</b> Re: [rules-users] Rules Engine always
running<br></font><br></div><div><span class="e" id="q_111999da18b29307_1">
<div></div> Alan,<br><br> If you have different sets of
rules that you want to apply in different circunstances, you can compile and
cache each of this sets as a rulebase (note that the set may contain a single
rule).<br> Then, for each fact that arrives, you decide which is the
rulebase that applies to it, create a working memory for that rulebase, assert
the fact, run the rule and throw the working memory away (as, you mentioned you
don't want this working memory anymore). <br><br> You can, of
course, work with a single rulebase and keep adding and removing rules from it,
but it will be more expensive to handle that for the use case you
described.<br><br> If you are able to detail your use case, we may
be able to help you more. <br><br>
Regards,<br> Edson<br><br><br>
<div><span class="gmail_quote">2007/3/28, Jones, Alan R <<a href="mailto:alan.r.jones@boeing.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">alan.r.jones@boeing.com</a>>:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Yes, some
of these things are being considered. Thanks for your input , it has been
helpful!</font></span></div>
<div> </div><br><br>
<p><span lang="en-us"><font face="Arial" size="2">aj</font></span> </p><br><br>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma" size="2"><span><b>From:</b> Anstis, Michael (M.)
[mailto:<a href="mailto:manstis1@ford.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">manstis1@ford.com</a>]
<br></span><b>Sent:</b> Wednesday, March 28, 2007 9:12 AM</font>
<div><span><font face="Tahoma" size="2"><br><b>To:</b> Rules Users List<br><b>Subject:</b> RE: [rules-users]
Rules Engine always running<br></font></span></div><br></div>
<div><span>
<div></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">I assume
rules are dynamically added to the Rulebase and that there is not a static set
of rules associated with each application release? </font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><font face="Arial"><font size="2"><font color="#0000ff"><span>I believe new rules can be dynamically added to the
existing Rulebase - whether existing WM's inherit the new rules I don't know.
Agenda Groups could provide the control of which groups of rules
fire.</span></font></font></font></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Also, if
you retain FactHandles to all asserted Facts depending upon the decision made
by the component the legacy Facts can be retracted before the new rule is
activated.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">I assume
you'll also have some "Rule life-cycle" control in place? Either removing
rules from a Rulebase (I believe to be possible) or destroying redundant WM's
(as per your proposal).</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Sorry,
this doesn't add much more value - although input from more experienced
users is welcomed.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Cheers,</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Mike</font></span></div><br>
<blockquote dir="ltr" style="margin-right: 0px;">
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma" size="2"><b>From:</b> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of
</b>Jones, Alan R<br><b>Sent:</b> 28 March 2007 15:29<br><b>To:</b> Rules
Users List<br><b>Subject:</b> RE: [rules-users] Rules Engine always
running<br></font><br></div>
<div></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Mike,</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Thanks
for you rresponse, however I'm not sure based on what we are wanting to
do that we should use a single working memory. The proposed
</font></span><span><font color="#0000ff" face="Arial" size="2">approach is:
</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">a rule
has been added to the rule base, then a Fact (object) comes along and we
instantiate a working memory and fire all rules relative to this working
memory. The outcome from Drools is evaluated by another sw component,
and it is decided to try a different rule with a given
Fact.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">So, a
new rule, rule #2, comes along with slightly different specifics on
what it is supposed to match, so it is added to the rule base. Then, Fact
#2 comes down the pipeline. A new working memory #2 is
instantiated against the existing rulebase, Fact #2 is asserted, and
fireAllRules() called against the working memory #2.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">The
desired behavior is that only rule #2 is actually kicked into action
(against Fact #2), since the first rule and fact is done with. We don't want
the previous rules/facts in the rule base operating any
longer. </font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Maybe I
just don't know enough about the proper application of rules when solving
particular problems to ask the right questions -- my task is to expose JBoss
rules as a service so I'm trying to understand a bit
about it's operation.</font></span></div>
<div><font color="#0000ff" face="Arial" size="2"></font> </div><span></span><font face="Arial"><font color="#0000ff"><font size="2">Thanks,<span></span></font></font></font><br><br>
<p><span lang="en-us"><font face="Arial" size="2">aj</font></span> </p><br>
<p><span lang="en-us"><font face="Arial" size="2">--------------------------------------------</font></span> <br><span lang="en-us"><font color="#0000ff" face="Arial" size="2">Alan R Jones</font></span>
<br><span lang="en-us"><font face="Arial" size="2">Boeing S&IS Mission
Systems</font></span> <br><span lang="en-us"><font face="Arial" size="2">Denver
Engineering Center (BDEC)</font></span> <br><span lang="en-us"><font face="Arial" size="2">303.307.3415</font></span> </p>
<div> </div><br>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma" size="2"><b>From:</b> Anstis, Michael (M.) [mailto:<a href="mailto:manstis1@ford.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">manstis1@ford.com</a>]
<br><b>Sent:</b> Wednesday, March 28, 2007 2:23 AM<br><b>To:</b> Rules Users
List<br><b>Subject:</b> RE: [rules-users] Rules Engine always
running<br></font><br></div>
<div></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Hi
Alan,</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">A
working memory is in essence always available\running whilst there is a
reference to it; other than the "main" thread (on which your public static
void main executes) you don't need to use other threads (but this obviously
depends upon what exactly you're trying to achieve). The Rulebase can
contain all of your production rules (in fact this is probably the
recommended approach as, assuming some rules share a common
pattern, the resulting RETE network will be optimised); and you can
feed incoming objects (Facts in JBoss Rules terms) into one working memory
created from the one Rulebase. As objects are asserted patterns (LHS)
defining the rules are matched and, once fully matched, rules are activated
for execution (RHS). <span><font color="#0000ff" face="Arial" size="2">Unfortunately I don't have any experience of JBoss Rules in a
multi-threaded environment.</font></span></font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"><span></span></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"><span></span>For example:-</font></span></div>
<blockquote dir="ltr" style="margin-right: 0px;">
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">public static void main(String args[]) {</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"> Rulebase rb =
loadRuleBase();</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"> WorkingMemory wm =
rb.newWorkingMemory();</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"> while (!exit()) {</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Courier New"><font size="2"> <font color="#0000ff">Collection c =
getObjectsFromWherever();</font></font></font></span></div>
<div dir="ltr" align="left"><span><font face="Courier New"><font size="2"> <font color="#0000ff">assertObjectsIntoWorkingMemory(c,
wm);</font></font></font></span></div>
<div dir="ltr" align="left"><span><font face="Courier New"><font size="2"> <font color="#0000ff">wm.fireAllRules();</font></font></font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"></font></span> </div>
<div dir="ltr" align="left"><span>
<font color="#0000ff" face="Courier New" size="2">try {</font></span></div>
<div dir="ltr" align="left"><span>
<font color="#0000ff" face="Courier New" size="2">Thread.sleep(1000);</font></span></div>
<div dir="ltr" align="left"><span>
<font color="#0000ff" face="Courier New" size="2">}</font></span></div>
<div dir="ltr" align="left"><span>
<font color="#0000ff" face="Courier New" size="2">catch(InterruptedException
ie) {</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"> }</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"> }</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">}</font></span></div></blockquote>
<div><font color="#0000ff"><font face="Arial" size="2">With kind regards,</font></font></div>
<div><font color="#0000ff"><font face="Arial" size="2"></font></font> </div>
<div><font size="-0"><font color="#0000ff"><font size="2"><font face="Arial">M<span>ike</span></font></font></font></font></div>
<div><br></div>
<blockquote dir="ltr" style="margin-right: 0px;">
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma" size="2"><b>From:</b> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users-bounces@lists.jboss.org</a> [mailto:
<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of
</b>Jones, Alan R<br><b>Sent:</b> 27 March 2007 19:05<br><b>To:</b> Rules
Users List<br><b>Subject:</b> [rules-users] Rules Engine always
running<br></font><br></div>
<div></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>Kind
of new to JBoss Rules...I'm trying to fiigure out from what i have read so
far if the following scenario is possible:</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>1.
Start up an instance of a working memory (say, with dummy rule?) and keep
it running, feeding it data objects to operate on from time to
time.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>2. As
needed, kick off as many instance of working memory within the single rule
base (in a separate thread) and keep them going as in step
1</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>The
idea is to keep the rules engine running constantly, but kick off separate
working-memory threads for the injection of various incoming rule
sets and the objects those rule sets work on as needed. Can anyone provide
some insight to this? Pointers to examples, perhaps?</span></font></div>
<div> </div><br><br>
<p><span lang="en-us"><font color="#0000ff" face="Arial" size="2"><span>Alan
J.</span></font></span> </p><br>
<p><font color="#0000ff" face="Arial" size="2"></font> </p></blockquote></blockquote></span></div></div><br>_______________________________________________<br>rules-users
mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer
- JBoss Rules Core Developer<br> Office: +55 11
3124-6000<br> Mobile: +55 11 9218-4151 <br> JBoss, a
division of Red Hat @ <a href="http://www.jboss.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">www.jboss.com</a>
</span></div></div>
<br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3124-6000<br> Mobile: +55 11 9218-4151
<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>