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&#39; conditions that operate on those &quot;inferred&quot; facts.<br>
<br>To get them back as results, you can either bind a global variable and add the results to it or use:<br><br>org.drools.StatelessSession#<br>    StatelessSessionResult executeWithResults(Collection collection);<br><br>
Cheers,<br>Leo.<br><br><br><br><div class="gmail_quote">2011/5/17 Greg Stasica <span dir="ltr">&lt;<a href="mailto:gstasica@pacemetrics.com">gstasica@pacemetrics.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


  
    
  
  <div bgcolor="#ffffff" text="#000000">
    hi,<br>
    you can&#39;t use stateless session for your problem.<br>
    <br>
    <a href="http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html/ch02.html#d0e254" target="_blank">http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html/ch02.html#d0e254</a><br>

    &quot;<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:&#39;Times New Roman&#39;;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="color:rgb(51, 51, 51);font-family:&#39;Lucida Grande&#39;,Geneva,Verdana,Arial,sans-serif;font-size:12px;line-height:18px;text-align:justify"><a>A stateless session can be called like a function
          passing it some data and then receiving some results back</a></span></span>&quot;<br>
    <br>
    the way i understand &quot;...receiving some results back&quot; 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<div><div></div><div class="h5"><br>
    <br>
    <br>
    On 06/05/2011 20:05, Dean Whisnant wrote:
    <blockquote type="cite">
      <pre>This is not an answer to your question, but rather asking the same question with a slight twist:

I&#39;m in the middle of trying to see if I can shift from stateful to stateless in my project and the &quot;session.getObjects&quot; 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: <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> [<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">mailto:rules-users-bounces@lists.jboss.org</a>] On Behalf Of aminmc
Sent: Saturday, April 16, 2011 2:31 PM
To: <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
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 &quot;open work item&quot;
    when
        Task ( status == &quot;OPEN&quot;)
    then
      insert(new Action(&quot;Take&quot;,&quot;take_task&quot;));
      insert(new Action(&quot;Complete&quot;,&quot;complete_task&quot;));
      insert(new Action(&quot;Close&quot;,&quot;close_task&quot;));

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&lt;Command&gt; commands = new ArrayList&lt;Command&gt;();
        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&#39;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: <a href="http://drools.46999.n3.nabble.com/Use-of-StatelessKnowledgeSession-tp2828548p2828548.html" target="_blank">http://drools.46999.n3.nabble.com/Use-of-StatelessKnowledgeSession-tp2828548p2828548.html</a>
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>

_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>

</pre>
    </blockquote>
    <br>
    </div></div><font color="#888888"><pre cols="72">-- 
Greg Stasica

PaceMetrics Ltd.
T  <a href="tel:%2B353%201%208849921" value="+35318849921" target="_blank">+353 1 8849921</a>

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 <a href="tel:%2B353%201%208184000" value="+35318184000" target="_blank">+353 1 8184000</a>. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.</pre>

  </font></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>