[rules-users] Drools Flow within Stateless Session in Drools 5.1

JeffMax jeffmax at gmail.com
Wed Dec 15 15:36:21 EST 2010


I am seeing some odd behavior where it seems that inference is not working
when trying to use a flow process within a stateless knowledge session. I
have tried to do the same thing in both stateful and stateless, and the
behavior is different.  It appears that if one rule inserts a fact in its
right hand side that causes another rule in a different flow-group to become
activated, the rule-flow (which should progress to the next flow group) will
not allow that rule to fire if the session is stateless. It is possible I am
confused about how a rule-flow evaluates or the order in which it evaluates
with respect to inference, but it is working as I expected in a stateful
session.

An example:

I have a simple rule flow with two flow-groups, group1 and group2. They are
connected one after the other
in a file with id TestFlow

start->group1 -> group2 -> end

I then have a simple rules file:

declare Fact1
  num: int
end

declare Fact2
  num: int
end

rule "Rule1"
    ruleflow-group "group1"
	when
		Fact1()
	then 
		System.out.print("FIRING 1");
		insert(new Fact2());
		
end

rule "Your Second Rule"
	ruleflow-group "group2"
	when
		Fact2()
	then 
		System.out.print("FIRING 2");
end


When used in a stateful session, both rules will fire and print their
respective output. In a stateless, the second rule will never fire. To
execute this test, I am using the same code against both a stateless and
stateful session:

FactType fact = kbase.getFactType("org.test", "Fact1");
Object one = fact.newInstance();
List cmds = new ArrayList();
cmds.add(CommandFactory.newInsert(one));
cmds.add(CommandFactory.newStartProcess("TestFlow"));
cmds.add(CommandFactory.newFireAllRules()); // Only need this in stateful
ksession.execute(CommandFactory.newBatchExecution(cmds));

Does anyone have any suggestions? 
Thanks, 
Jeff

-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-within-Stateless-Session-in-Drools-5-1-tp2094451p2094451.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list