<!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=075205708-06022008><FONT face=Arial
color=#0000ff size=2>Nope, stateless can have multiple objects inserted prior to
rule invocation (look at the overloaded execute method).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=075205708-06022008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=075205708-06022008><FONT face=Arial
color=#0000ff size=2>Stateful are best suited when you need to insert
different facts over the course of a "rule session" and the state of previous
facts may affect the interpretation of new facts. </FONT></SPAN><SPAN
class=075205708-06022008><FONT face=Arial color=#0000ff size=2>Stateless cleans
itself up after execution. </FONT></SPAN><SPAN class=075205708-06022008><FONT
face=Arial color=#0000ff size=2>I assume you're exposing the rules as a
web-service over HTTP in which case each HTTP request will represent a stateless
invocation of the rules and hence stateless would IMO be preferable.
</FONT></SPAN><SPAN class=075205708-06022008><FONT face=Arial color=#0000ff
size=2>This leads to better scalability (as you don't need to store session
information in [web-server] memory) and is more resilient (as you don't need to
concern yourself with HTTP sessions being timed out on the server and you trying
to recover).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=075205708-06022008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=075205708-06022008><FONT face=Arial
color=#0000ff size=2>With kind regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=075205708-06022008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=075205708-06022008><FONT face=Arial
color=#0000ff size=2>Mike</FONT></SPAN></DIV><BR>
<BLOCKQUOTE 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>Jai
Vasanth<BR><B>Sent:</B> 05 February 2008 19:27<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>I see. Yes , I must have confused myself with sequential stateless
and stateless. So from what I can infer, the main advantage of statefull
session over a stateless is that we can insert multiple objects into the
working memory before calling fireAllRules() as opposed to the stateless where
we need to fire rules based on just 1 fact object? What are the other
differences that I need to know if I have to evaluate using stateless
sessions.<BR><BR>Thanks<BR><BR>Jai <BR><BR>
<DIV class=gmail_quote>On Feb 5, 2008 1:57 AM, Anstis, Michael (M.) <<A
href="mailto:manstis1@ford.com">manstis1@ford.com</A>> 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>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><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2><B><I>DRL</I></B></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2>package
com.<SPAN>test</SPAN><BR> <BR>import <SPAN>com.test.</SPAN><SPAN>Fact1</SPAN>;<BR>import <SPAN>com.test.</SPAN><SPAN>Fact2</SPAN>;<BR> <BR>rule
"<SPAN>Fact</SPAN>1"<BR> when<BR> <SPAN>Fact1</SPAN>()<BR> then<BR> System.out.println("<SPAN>Fact1</SPAN>");<BR> insert(new <SPAN>Fact</SPAN>2());<BR>end</FONT></DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2>rule
"<SPAN>Fact</SPAN>2"<BR> when<BR> <SPAN>Fact</SPAN>2(
)<BR> then<BR> System.out.println("<SPAN>Fact</SPAN>2");
<BR>end</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><B><I>Java</I></B></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="Courier New" color=#0000ff
size=2>StatelessSession session =
ruleBase.newStatelessSession();</FONT></SPAN></DIV>
<DIV><SPAN><FONT face="Courier New" color=#0000ff size=2>session.execute(new
Fact1());</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN></SPAN><FONT color=#0000ff><FONT size=2><FONT
face=Arial><B><I>C<SPAN>onsole</SPAN></I></B></FONT></FONT></FONT></DIV><FONT
face="Courier New"><FONT color=#0000ff><FONT
size=2><SPAN></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><FONT face="Courier New" color=#0000ff
size=2>Fact1</FONT></SPAN></DIV>
<DIV><SPAN><FONT face="Courier New" color=#0000ff
size=2>Fact2</FONT></SPAN></DIV>
<DIV lang=en-us align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV lang=en-us align=left><SPAN><FONT face=Arial color=#0000ff size=2>Are
you getting (general) stateless sessions confused with sequential
stateless sessions?</FONT></SPAN></DIV>
<DIV lang=en-us align=left><SPAN></SPAN> </DIV>
<DIV lang=en-us align=left><SPAN><FONT face=Arial color=#0000ff size=2>With
kind regards,</FONT></SPAN></DIV>
<DIV lang=en-us align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV lang=en-us align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Mike</FONT> </SPAN></DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left><SPAN></SPAN> </DIV>
<DIV lang=en-us dir=ltr align=left>
<HR>
</DIV>
<DIV lang=en-us dir=ltr align=left><FONT face=Tahoma size=2>
<DIV class=Ih2E3d><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> 04 February 2008 21:02
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c><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></DIV></DIV></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c>
<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 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.) <<A
href="mailto:manstis1@ford.com" target=_blank>manstis1@ford.com</A>>
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> </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> </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 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> <BR> RuleBase ruleBase =
RuleBaseFactory.newRuleBase();<BR>ruleBase.addPackage( pkg
);<BR><BR>PER REQUEST:<BR>Stateful session =
ruleBase.newStatefulSession(); (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 <<A
href="mailto:mrhoden@franklinamerican.com"
target=_blank>mrhoden@franklinamerican.com</A>> 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 vlink="purple" link="blue">
<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> </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> </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> </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> </P>
<P><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Hi,<BR><BR> 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 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></DIV></DIV></BLOCKQUOTE></DIV><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><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>