My question is if I call re.callRuleEngine(facts) in the same thread (which
in turn calls knowledgeSession.fireallrules()) will it "block" till
a) ALL rules are fired (i.e., THEN part of rule is executed for all
matching facts in working memory)
AND
b) MyChannel.send() is executed for all matching facts i.e., the list of
FilteredFacts inside my MyChannel object is populated completely at the end
of the blocking call.
Thanks.
-------------------------------------------------------------------------------------
RuleEngine re = RuleEngine();
re.callRuleEngine(facts);
-----------------------------------------------------------------------------------
rule.drl
rule "some_rule"
dialect "mvel"
when
$my_var : MyValueObject( x > 4.0 )
then
channels["my_drools_channel"].send($my_var);
end
-----------------------------------------------------------------------------------
RuleEngine
{
RuleEngine{
KnowledgeBase knowledgeBase = null;
try {
knowledgeBase = createKnowledgeBase();
} catch (Exception e) {
e.printStackTrace();
}
knowledgeSession = knowledgeBase.newStatefulKnowledgeSession();
knowledgeSession.registerChannel("my_drools_channel", new MyChannel());
}
void callRuleEngine(List<MyValueObject> facts)
{
// insert Facts into
// the working memory.
for (Object fact : facts) {
knowledgeSession.insert(fact);
}
knowledgeSession.fireallrules();
}
}
-----------------------------------------------------------------------------------
public class MyChannel implements Channel {
private List<MyValueObject> filteredFacts;
@Override
public void send(Object object) {
if( object instanceof MyValueObject )
{
MyValueObject obj = (MyValueObject)object;
filteredFacts.add(obj)
}
}
}
--
View this message in context:
http://drools.46999.n3.nabble.com/Will-StatefulKnowledgeSession-fireallru...
Sent from the Drools: User forum mailing list archive at
Nabble.com.