[rules-users] How to continue session, but remove all objects?

Wolfgang Laun wolfgang.laun at gmail.com
Wed Dec 15 10:36:21 EST 2010


In this case, I would just use clear out the working memory:
  for( Person p: ... ){
     insert( p );
     ksession.fireAllRules();
     for( Object object: ksession.getObjects() ){
        ksession.retract( ksession.getFactHandle( object ) );
     }
   }

without recreating another ksession for the next Person (no dispose(), no
newStatefulKnowledgeSession() )

But there's
   ksession.startProcess(this.file);
and anything might happen there, so all bets are off...

-W


On 15 December 2010 16:14, saynyshy <saynyshy at gmail.com> wrote:

>
> Sorry, I couldn't explain it correctly (first time you understand me
> correct)
>
> So, please see the code (no it was really realised as you said before ->
> every time start new session but...)
> I'l try to show example:
>
>
> private KnowledgeBase kbase;
> ...
> kbase = readKnowledgeBase(ruleflowfileSheme, rulefileslistDrl);
> kbase.newStatefulKnowledgeSession();
> ...
>
> I need to check some Persons in rules:
>
> List<Person>ls
>
> for(Person p:ls){
>
> check(p);
>
> }
>
> I'm using method
>
> public boolean check(Person p){
> StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
> ...
>                ksession.insert(p);
>                ksession.startProcess(this.file);
>                ksession.fireAllRules();
>                ksession.dispose();
>
>                // here i need remove all objects from memory (all
> drools.insert's etc) &
> p too...
>                return false;
> }
>
>
>
> Every time I use new session, because i can't remove all objects from
> memory
> after (current checked list element)
> Person p was checked in all rules. How can I do this????
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/How-to-continue-session-but-remove-all-objects-tp2090965p2092517.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101215/c9fc4c6e/attachment.html 


More information about the rules-users mailing list