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="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">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 color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"><b><i>DRL</i></b></font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><font color="#0000ff" face="Courier New" 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 color="#0000ff" face="Courier New" size="2"></font> </div>
<div><font color="#0000ff" face="Courier New" 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 color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"><b><i>Java</i></b></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="Courier New" size="2">StatelessSession session =
ruleBase.newStatelessSession();</font></span></div>
<div><span><font color="#0000ff" face="Courier New" size="2">session.execute(new Fact1());</font></span></div>
<div><font color="#0000ff" face="Arial" 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 color="#0000ff" face="Courier New" size="2"></font><font color="#0000ff" face="Courier New" size="2"></font><font color="#0000ff" face="Courier New" size="2"></font>
<div><font color="#0000ff" face="Arial" size="2"></font><font color="#0000ff" face="Arial" size="2"></font><br><span><font color="#0000ff" face="Courier New" size="2">Fact1</font></span></div>
<div><span><font color="#0000ff" face="Courier New" size="2">Fact2</font></span></div>
<div align="left" lang="en-us"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div align="left" lang="en-us"><span><font color="#0000ff" face="Arial" size="2">Are you getting
(general) stateless sessions confused with sequential stateless
sessions?</font></span></div>
<div align="left" lang="en-us"><span></span> </div>
<div align="left" lang="en-us"><span><font color="#0000ff" face="Arial" size="2">With kind
regards,</font></span></div>
<div align="left" lang="en-us"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div align="left" lang="en-us"><span><font color="#0000ff" face="Arial" size="2">Mike</font> </span></div>
<blockquote style="margin-right: 0px;">
<div dir="ltr" align="left" lang="en-us"><span> </span></div>
<div dir="ltr" align="left" lang="en-us">
<hr>
</div>
<div dir="ltr" align="left" lang="en-us"><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="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">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 color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" 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 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 style="margin-right: 0px;">
<div dir="ltr" align="left" lang="en-us">
<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="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p><font color="navy" face="Arial" 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 color="navy" face="Arial" size="2"><span style="font-size: 10pt; color: navy; font-family: Arial;"></span></font> </p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; color: navy; font-family: Arial;">Rulebase =
once</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; color: navy; font-family: Arial;">Working memory
= per user/transaction</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; color: navy; font-family: Arial;"></span></font> </p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; color: navy; font-family: Arial;">-Michael</span></font></p>
<p><font color="navy" face="Arial" 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" size="2" width="100%">
</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>