<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=798470717-28032007><FONT face=Arial
color=#0000ff size=2>This is actually very close to the approach I am going to
try:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=798470717-28032007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=798470717-28032007><FONT face=Arial
color=#0000ff 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 class=798470717-28032007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=798470717-28032007><FONT face=Arial
color=#0000ff size=2>Thanks,</FONT></SPAN><!-- Converted from text/rtf format --><BR><BR></DIV>
<P><SPAN lang=en-us><FONT face=Arial size=2>aj</FONT></SPAN> </P>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Edson Tirelli [mailto:tirelli@post.com]
<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></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">alan.r.jones@boeing.com</A>>:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><SPAN class=q><B>From:</B> Anstis, Michael (M.)
[mailto:<A onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:manstis1@ford.com" target=_blank>manstis1@ford.com</A>]
<BR></SPAN><B>Sent:</B> Wednesday, March 28, 2007 9:12 AM</FONT>
<DIV><SPAN class=e id=q_1119963a6d7fc056_3><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 class=e id=q_1119963a6d7fc056_5>
<DIV></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Mike</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>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 face=Arial color=#0000ff
size=2>Mike,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff size=2>approach is:
</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
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 face=Arial color=#0000ff 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 lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> Anstis, Michael (M.) [mailto:<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:manstis1@ford.com" target=_blank>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 face=Arial color=#0000ff size=2>Hi
Alan,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff
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 face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN>For example:-</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>public static void main(String args[]) {</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> Rulebase rb =
loadRuleBase();</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> WorkingMemory wm =
rb.newWorkingMemory();</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> while (!exit()) {</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
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 face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr
align=left><SPAN>
<FONT face="Courier New" color=#0000ff size=2>try {</FONT></SPAN></DIV>
<DIV dir=ltr
align=left><SPAN>
<FONT face="Courier New" color=#0000ff
size=2>Thread.sleep(1000);</FONT></SPAN></DIV>
<DIV dir=ltr
align=left><SPAN>
<FONT face="Courier New" color=#0000ff size=2>}</FONT></SPAN></DIV>
<DIV dir=ltr
align=left><SPAN>
<FONT face="Courier New" color=#0000ff size=2>catch(InterruptedException
ie) {</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> }</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> }</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
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 lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>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 face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff 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 face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 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 face=Arial color=#0000ff size=2><SPAN>Alan
J.</SPAN></FONT></SPAN> </P><BR>
<P><FONT face=Arial color=#0000ff
size=2></FONT> </P></BLOCKQUOTE></BLOCKQUOTE></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>
</BODY></HTML>