Inserting new facts in the THEN clause (RHS) is possible in a stateless
session (except if you set it to run in sequential mode). You can also
create rules' conditions that operate on those "inferred" facts.

To get them back as results, you can either bind a global variable and add
the results to it or use:

org.drools.StatelessSession#
    StatelessSessionResult executeWithResults(Collection collection);

Cheers,
Leo.



2011/5/17 Greg Stasica <[email protected]>

>  hi,
> you can't use stateless session for your problem.
>
>
> http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html/ch02.html#d0e254
> "A stateless session can be called like a function passing it some data
> and then receiving some results back"
>
> the way i understand "...receiving some results back" part is that facts
> can be updated (you can call methods on them) but inserting any new facts
> into session in WHEN section is not possible
>
>
>
> On 06/05/2011 20:05, Dean Whisnant wrote:
>
> This is not an answer to your question, but rather asking the same question 
> with a slight twist:
>
> I'm in the middle of trying to see if I can shift from stateful to stateless 
> in my project and the "session.getObjects" method is what we would use in 
> stateful as well to read back all of the new objects created during rules 
> execution.  My project seems to be much more geared towards stateless and 
> thus far testing has shown our time would benefit significantly from the 
> change.
>
> I see in the docs where ExecutionResults are used with the execute:
>
>                       ExecutionResults results = 
> ksession.execute(CommandFactory.newBatchExecution( cmds) );
>
> But even within results I do not see how to gather my objects from memory.
>
> Any thoughts on what I am missing here?
>
> Thanks
>
> Dean
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected] 
> <[email protected]>] On Behalf Of aminmc
> Sent: Saturday, April 16, 2011 2:31 PM
> To: [email protected]
> Subject: [rules-users] Use of StatelessKnowledgeSession
>
> Hi there
>
> I was wondering if someone might be able to help with what I am trying to do. 
>  I have the following rule definition:
>
> rule "open work item"
>     when
>         Task ( status == "OPEN")
>     then
>       insert(new Action("Take","take_task"));
>       insert(new Action("Complete","complete_task"));
>       insert(new Action("Close","close_task"));
>
> end
>
> Basically I want to insert a Task and then get back a list of Actions that 
> are available for the Task (based on the status.  I have this working with a 
> statefulknowledgesession with the code:
>
>  List<Command> commands = new ArrayList<Command>();
>         for (Task task : tasks) {
>             commands.add(CommandFactory.newInsert(task));
>         }
>         session.execute(CommandFactory.newBatchExecution(commands));
>         session.fireAllRules();
>         session.dispose();
>
>        //this returns the actions
>        Collection objects = session.getObjects(new 
> ClassObjectFilter(Action.class));
>
> I was wondering whether it is possible to do this with a 
> statelessknowledgesession instead?  I could'nt see how to achieve this 
> without updating the task to include the actions.
>
> Any help would be appreciated.
>
> Cheers
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/Use-of-StatelessKnowledgeSession-tp2828548p2828548.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing 
> [email protected]https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing 
> [email protected]https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> --
> Greg Stasica
>
> PaceMetrics Ltd.
> T  +353 1 8849921
>
> PaceMetrics Limited is registered in Ireland as a private company limited by 
> shares, Registration  No.  298243,  Registered office:  PaceMetrics House, 
> East Point Business Park, Dublin 3. This e-mail may contain confidential, 
> proprietary or privileged information. If you are not the intended recipient 
> (or have received this e-mail in error) please destroy this e-mail and notify 
> the sender immediately by telephoning +353 1 8184000. Any unauthorized 
> copying, disclosure or distribution of the material in this e-mail is 
> strictly forbidden.
>
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to