<!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.3132" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face=Arial 
color=#0000ff size=2>Obviously you know your requirments better than I, but the 
following stateless example accommodates dynamic insertion of 
facts:-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face=Arial 
color=#0000ff size=2><STRONG><EM>DRL</EM></STRONG></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2>package com.<SPAN 
class=221175309-05022008>test</SPAN><BR>&nbsp;<BR>import&nbsp;<SPAN 
class=221175309-05022008>com.test.</SPAN><SPAN 
class=221175309-05022008>Fact1</SPAN>;<BR>import&nbsp;<SPAN 
class=221175309-05022008>com.test.</SPAN><SPAN 
class=221175309-05022008>Fact2</SPAN>;<BR>&nbsp;<BR>rule "<SPAN 
class=221175309-05022008>Fact</SPAN>1"<BR>&nbsp;when<BR>&nbsp;&nbsp;<SPAN 
class=221175309-05022008>Fact1</SPAN>()<BR>&nbsp;then<BR>&nbsp;&nbsp;System.out.println("<SPAN 
class=221175309-05022008>Fact1</SPAN>");<BR>&nbsp;&nbsp;insert(new&nbsp;<SPAN 
class=221175309-05022008>Fact</SPAN>2());<BR>end</FONT></DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2>rule "<SPAN 
class=221175309-05022008>Fact</SPAN>2"<BR>&nbsp;when<BR>&nbsp;&nbsp;<SPAN 
class=221175309-05022008>Fact</SPAN>2( 
)<BR>&nbsp;then<BR>&nbsp;&nbsp;System.out.println("<SPAN 
class=221175309-05022008>Fact</SPAN>2"); <BR>end</FONT></DIV>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face=Arial 
color=#0000ff size=2><STRONG><EM>Java</EM></STRONG></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=221175309-05022008><FONT face="Courier New" 
color=#0000ff size=2>StatelessSession session = 
ruleBase.newStatelessSession();</FONT></SPAN></DIV>
<DIV><SPAN class=221175309-05022008><FONT face="Courier New" color=#0000ff 
size=2>session.execute(new Fact1());</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=221175309-05022008></SPAN><FONT color=#0000ff><FONT 
size=2><FONT face=Arial><STRONG><EM>C<SPAN 
class=221175309-05022008>onsole</SPAN></EM></STRONG></FONT></FONT></FONT></DIV><FONT 
face="Courier New"><FONT color=#0000ff><FONT size=2><SPAN 
class=221175309-05022008></SPAN></FONT></FONT></FONT><FONT face="Courier New" 
color=#0000ff size=2></FONT><FONT face="Courier New" color=#0000ff 
size=2></FONT><FONT face="Courier New" color=#0000ff size=2></FONT>
<DIV><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff 
size=2></FONT><BR><SPAN class=221175309-05022008><FONT face="Courier New" 
color=#0000ff size=2>Fact1</FONT></SPAN></DIV>
<DIV><SPAN class=221175309-05022008><FONT face="Courier New" color=#0000ff 
size=2>Fact2</FONT></SPAN></DIV>
<DIV class=OutlookMessageHeader lang=en-us align=left><SPAN 
class=221175309-05022008><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV class=OutlookMessageHeader lang=en-us align=left><SPAN 
class=221175309-05022008><FONT face=Arial color=#0000ff size=2>Are you getting 
(general) stateless sessions&nbsp;confused with sequential stateless 
sessions?</FONT></SPAN></DIV>
<DIV class=OutlookMessageHeader lang=en-us align=left><SPAN 
class=221175309-05022008></SPAN>&nbsp;</DIV>
<DIV class=OutlookMessageHeader lang=en-us align=left><SPAN 
class=221175309-05022008><FONT face=Arial color=#0000ff size=2>With kind 
regards,</FONT></SPAN></DIV>
<DIV class=OutlookMessageHeader lang=en-us align=left><SPAN 
class=221175309-05022008><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV class=OutlookMessageHeader lang=en-us align=left><SPAN 
class=221175309-05022008><FONT face=Arial color=#0000ff 
size=2>Mike</FONT>&nbsp;</SPAN></DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><SPAN 
  class=221175309-05022008>&nbsp;</SPAN></DIV>
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  </DIV>
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><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>Jai 
  Vasanth<BR><B>Sent:</B> 04 February 2008 21:02<BR><B>To:</B> Rules Users 
  List<BR><B>Subject:</B> Re: [rules-users] Using the drools as the backend 
  engine for a service<BR></FONT><BR></DIV>
  <DIV></DIV>As part of the rules evaluation, more objects are inserted into the 
  working memory. Even though I just insert 1 object after creating a session, 
  rule outcomes inside lead to more objects to&nbsp; be inserted. <BR>Correct me 
  if I am wrong, but I was under the impression that a stateless wouldnt be able 
  to automatically fire rules when we objects are inserted 
  dynamically<BR><BR>Thanks<BR><BR>Jai<BR><BR>
  <DIV class=gmail_quote>On Feb 4, 2008 1:05 AM, Anstis, Michael (M.) &lt;<A 
  href="mailto:manstis1@ford.com" target=_blank>manstis1@ford.com</A>&gt; 
  wrote:<BR>
  <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>IMHO, 
    you might achieve better scalability and resilience if you can make the 
    working memory stateless.</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>I assume 
    your "service" to be a web-service over stateless-HTTP and not a service 
    exposed over a stateful protocol.</FONT></SPAN></DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</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>&nbsp;</DIV>
    <DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 
    size=2>Mike</FONT></SPAN></DIV><BR>
    <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
      <DIV lang=en-us dir=ltr align=left>
      <HR>
      <FONT face=Tahoma size=2>
      <DIV><B>From:</B> <A href="mailto:rules-users-bounces@lists.jboss.org" 
      target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A 
      href="mailto:rules-users-bounces@lists.jboss.org" 
      target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf Of 
      </B>Jai Vasanth<BR></DIV><B>Sent:</B> 01 February 2008 22:05<BR><B>To:</B> 
      Rules Users List<BR><B>Subject:</B> Re: [rules-users] Using the drools as 
      the backend engine for a service<BR></FONT><BR></DIV>
      <DIV>
      <DIV></DIV>
      <DIV>
      <DIV></DIV>I must have not been clear, yes I was planning on instantiating 
      the rulebase when the service starts and instantiating a new session for 
      every request.<BR><BR><BR><BR>ONCE:<BR>&nbsp;<BR>&nbsp;RuleBase ruleBase = 
      RuleBaseFactory.newRuleBase();<BR>ruleBase.addPackage( pkg );<BR><BR>PER 
      REQUEST:<BR>Stateful session = ruleBase.newStatefulSession();&nbsp; (Is 
      this what you were referring to as working memory ? )<BR><BR><BR>I hope 
      that looks ok.<BR><BR>Thanks<BR><BR>Jai <BR>
      <DIV class=gmail_quote>On Feb 1, 2008 1:37 PM, Michael Rhoden &lt;<A 
      href="mailto:mrhoden@franklinamerican.com" 
      target=_blank>mrhoden@franklinamerican.com</A>&gt; wrote:<BR>
      <BLOCKQUOTE class=gmail_quote 
      style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
        <DIV lang=EN-US link="blue" vlink="purple">
        <DIV>
        <P><FONT face=Arial color=navy size=2><SPAN 
        style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">You would 
        likely NOT want to create a rulebase per session. Most people create 
        working memory per session. Rulebases should only be loaded once per 
        server (context) in my opinion, and you reload it as rules changes. 
        Loading a rulebase loads rules from a file, and orders your rete tree. 
        For our installation that takes several minutes.</SPAN></FONT></P>
        <P><FONT face=Arial color=navy size=2><SPAN 
        style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
        <P><FONT face=Arial color=navy size=2><SPAN 
        style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Rulebase = 
        once</SPAN></FONT></P>
        <P><FONT face=Arial color=navy size=2><SPAN 
        style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Working memory 
        = per user/transaction</SPAN></FONT></P>
        <P><FONT face=Arial color=navy size=2><SPAN 
        style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
        <P><FONT face=Arial color=navy size=2><SPAN 
        style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">-Michael</SPAN></FONT></P>
        <P><FONT face=Arial color=navy size=2><SPAN 
        style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
        <DIV>
        <DIV style="TEXT-ALIGN: center" align=center><FONT 
        face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
        <HR align=center width="100%" SIZE=2>
        </SPAN></FONT></DIV>
        <P><B><FONT face=Tahoma size=2><SPAN 
        style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT 
        face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"> 
        <A href="mailto:rules-users-bounces@lists.jboss.org" 
        target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A 
        href="mailto:rules-users-bounces@lists.jboss.org" 
        target=_blank>rules-users-bounces@lists.jboss.org</A>] <B><SPAN 
        style="FONT-WEIGHT: bold">On Behalf Of </SPAN></B>Jai 
        Vasanth<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Friday, 
        February 01, 2008 3:23 PM<BR><B><SPAN 
        style="FONT-WEIGHT: bold">To:</SPAN></B> Rules Users List<BR><B><SPAN 
        style="FONT-WEIGHT: bold">Subject:</SPAN></B> [rules-users] Using the 
        drools as the backend engine for a service</SPAN></FONT></P></DIV>
        <DIV>
        <DIV></DIV>
        <DIV>
        <P><FONT face="Times New Roman" size=3><SPAN 
        style="FONT-SIZE: 12pt"></SPAN></FONT>&nbsp;</P>
        <P><FONT face="Times New Roman" size=3><SPAN 
        style="FONT-SIZE: 12pt">Hi,<BR><BR>&nbsp;I am planning on using Drools 
        as the rules engine for a service that I am building. I am considering 
        instantiating a stateful session for every request to the service. The 
        RuleBase would be created when the service starts. Is this the correct 
        way to&nbsp; go about incorporating Drools in a service ? Is session 
        creation an expensive process and if so are there other efficient ways 
        of doing so ?<BR><BR><BR><BR>Thanks <BR><BR>Jai 
        </SPAN></FONT></P></DIV></DIV></DIV></DIV><BR>_______________________________________________<BR>rules-users 
        mailing list<BR><A href="mailto:rules-users@lists.jboss.org" 
        target=_blank>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></BLOCKQUOTE></DIV><BR></DIV></DIV></BLOCKQUOTE></DIV><BR>_______________________________________________<BR>rules-users 
    mailing list<BR><A href="mailto:rules-users@lists.jboss.org" 
    target=_blank>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></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>