<!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.2873" name=GENERATOR></HEAD>
<BODY 
style="WORD-WRAP: break-word; khtml-nbsp-mode: space; khtml-line-break: after-white-space">
<DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT face=Arial 
color=#0000ff size=2>Hi Alan,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=714460308-28032007><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&nbsp;a common pattern,&nbsp;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 
class=714460308-28032007><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 class=714460308-28032007><FONT face=Arial 
color=#0000ff size=2><SPAN 
class=714460308-28032007></SPAN></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT face=Arial 
color=#0000ff size=2><SPAN class=714460308-28032007></SPAN>For 
example:-</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2>public static void main(String args[]) 
  {</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2>&nbsp;&nbsp;&nbsp; Rulebase rb = 
  loadRuleBase();</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2>&nbsp;&nbsp;&nbsp; WorkingMemory wm = 
  rb.newWorkingMemory();</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2>&nbsp;&nbsp;&nbsp; while (!exit()) 
  {</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New"><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <FONT color=#0000ff>Collection c = 
  getObjectsFromWherever();</FONT></FONT></FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New"><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <FONT color=#0000ff>assertObjectsIntoWorkingMemory(c, 
  wm);</FONT></FONT></FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New"><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <FONT color=#0000ff>wm.fireAllRules();</FONT></FONT></FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN 
  class=714460308-28032007>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <FONT face="Courier New" color=#0000ff size=2>try {</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN 
  class=714460308-28032007>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <FONT face="Courier New" color=#0000ff 
  size=2>Thread.sleep(1000);</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN 
  class=714460308-28032007>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <FONT face="Courier New" color=#0000ff size=2>}</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN 
  class=714460308-28032007>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <FONT face="Courier New" color=#0000ff size=2>catch(InterruptedException ie) 
  {</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff 
  size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2>&nbsp;&nbsp;&nbsp; 
  }</FONT></SPAN></DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV dir=ltr align=left><SPAN class=714460308-28032007><FONT 
  face="Courier New" color=#0000ff size=2>}</FONT></SPAN></DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff><FONT face=Arial 
size=2>With&nbsp;kind&nbsp;regards,</FONT></FONT></DIV>
<DIV><FONT color=#0000ff><FONT face=Arial size=2></FONT></FONT>&nbsp;</DIV>
<DIV><FONT><FONT color=#0000ff><FONT size=2><FONT face=Arial>M<SPAN 
class=714460308-28032007>ike</SPAN></FONT></FONT></FONT></FONT></DIV>
<DIV><BR></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org 
  [mailto:rules-users-bounces@lists.jboss.org] <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 
  class=466345717-27032007>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 
  class=466345717-27032007></SPAN></FONT>&nbsp;</DIV>
  <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
  class=466345717-27032007></SPAN></FONT>&nbsp;</DIV>
  <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
  class=466345717-27032007>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 
  class=466345717-27032007>2. As needed, kick off as many instance of working 
  memory within the single rule base (in a separate thread)&nbsp;and keep them 
  going as in step 1</SPAN></FONT></DIV>
  <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
  class=466345717-27032007></SPAN></FONT>&nbsp;</DIV>
  <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
  class=466345717-27032007>The idea is to keep the rules engine running 
  constantly, but kick off separate working-memory threads for the injection 
  of&nbsp;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>&nbsp;</DIV><!-- Converted from text/rtf format --><BR><BR>
  <P><SPAN lang=en-us><FONT face=Arial color=#0000ff size=2><SPAN 
  class=466345717-27032007>Alan J.</SPAN></FONT></SPAN>&nbsp;</P><BR>
  <P><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</P></BLOCKQUOTE></BODY></HTML>