Nope, stateless can have multiple objects inserted prior to rule invocation (look at the overloaded execute method).
 
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. Stateless cleans itself up after execution. 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. 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).
 
With kind regards,
 
Mike


From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Jai Vasanth
Sent: 05 February 2008 19:27
To: Rules Users List
Subject: Re: [rules-users] Using the drools as the backend engine for a service

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.

Thanks

Jai

On Feb 5, 2008 1:57 AM, Anstis, Michael (M.) <manstis1@ford.com> wrote:
Obviously you know your requirments better than I, but the following stateless example accommodates dynamic insertion of facts:-
 
DRL
 
package com.test
 
import com.test.Fact1;
import com.test.Fact2;
 
rule "Fact1"
 when
  Fact1()
 then
  System.out.println("Fact1");
  insert(new Fact2());
end
 
rule "Fact2"
 when
  Fact2( )
 then
  System.out.println("Fact2");
end
 
Java
 
StatelessSession session = ruleBase.newStatelessSession();
session.execute(new Fact1());
 
Console

Fact1
Fact2
 
Are you getting (general) stateless sessions confused with sequential stateless sessions?
 
With kind regards,
 
Mike 
 

Sent: 04 February 2008 21:02

To: Rules Users List
Subject: Re: [rules-users] Using the drools as the backend engine for a service

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.
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

Thanks

Jai

On Feb 4, 2008 1:05 AM, Anstis, Michael (M.) <manstis1@ford.com> wrote:
IMHO, you might achieve better scalability and resilience if you can make the working memory stateless.
 
I assume your "service" to be a web-service over stateless-HTTP and not a service exposed over a stateful protocol.
 
Cheers,
 
Mike


Sent: 01 February 2008 22:05
To: Rules Users List
Subject: Re: [rules-users] Using the drools as the backend engine for a service

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.



ONCE:
 
 RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );

PER REQUEST:
Stateful session = ruleBase.newStatefulSession();  (Is this what you were referring to as working memory ? )


I hope that looks ok.

Thanks

Jai
On Feb 1, 2008 1:37 PM, Michael Rhoden <mrhoden@franklinamerican.com> wrote:

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.

 

Rulebase = once

Working memory = per user/transaction

 

-Michael

 


From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Jai Vasanth
Sent: Friday, February 01, 2008 3:23 PM
To: Rules Users List
Subject: [rules-users] Using the drools as the backend engine for a service

 

Hi,

 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 ?



Thanks

Jai


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users