[rules-users] Why StatelessKnowledgeSession Instantiates a New StatefulKnowledgeSession on Each execute()?

yj h hyjshanghai at gmail.com
Sun Jan 30 07:53:58 EST 2011


I see. Thank you.
For instance, retracting a fact with lots of pending activations associated
with this fact could me expensive. Am I right?

2011/1/27 Esteban Aliverti <esteban.aliverti at gmail.com>

> Sessions are cheap to create.
> The problem of removing all the facts and then insert new ones is that
> depending on you rules, could be much more expensive than throw the old
> session and create a new one. And you should also think about globals as
> well. Removing a Fact is not just taking it off from a list. There is a lot
> of logic involved there.
> Is like if you have a populated List and you want to remove all its items
> and fill it with new ones (from another List for example).
> What would you use?
>
> originalList.clear();
> originalList.addAll(anotherList);
>
> or
>
> originalList = new ArrayList(anotherList);
>
> Best Regards,
>
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
>
>
> On Thu, Jan 27, 2011 at 5:45 AM, hyjshanghai <hyjshanghai at gmail.com>wrote:
>
>>
>> According to Section 3.3.7 "StatelessKnowledgeSession" of
>>
>> http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html/ch03.html#d0e1956
>> the Drools document , "the act of calling execute() is a single-shot
>> method
>> that will internally instantiate a StatefulKnowledgeSession".
>>
>> Why StatelessKnowledgeSession instantiates a new statefulKnowledgeSession
>> object on Each execute()?
>>
>> Instead, can it be implemented as inserting the fact into an existing
>> empty
>> statefulKnowledgeSession, and retract the fact after
>> statefulKnowledgeSession.fireAllRules()?
>>
>> I think the current implementation will cause StatelessKnowledgeSession
>>  to
>> be slower than statefulKnowledgeSession, as opposed to "common sense" that
>> the former is less complex and should be faster. Any performance benchmark
>> on Stateless v.s. Stateful Sessions?
>> --
>> View this message in context:
>> http://drools-java-rules-engine.46999.n3.nabble.com/Why-StatelessKnowledgeSession-Instantiates-a-New-StatefulKnowledgeSession-on-Each-execute-tp2360846p2360846.html
>> Sent from the Drools - User mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Best Wishes,
Huang, Yijian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110130/b46b40ae/attachment.html 


More information about the rules-users mailing list