[rules-users] Use of StatelessKnowledgeSession

Dean Whisnant dean at basys.com
Fri May 6 15:05:06 EDT 2011


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: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of aminmc
Sent: Saturday, April 16, 2011 2:31 PM
To: rules-users at lists.jboss.org
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 list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list