I’m having some difficulty getting a rule flow with a
stateless session to work. Essentially, it is just
executing the first task and then stops. I’m using Drools
5.1.1 and I just built the sample Drools by creating a new
Drools Project.
My rule flow is simple: Start-RuleGroup1-RuleGroup2-End
I use the 2 rules from example, putting the “Hello World”
in RuleGroup1 and “Goodbye” in RuleGroup2.
Here’s my code to run it:
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatelessKnowledgeSession ksession =
kbase.newStatelessKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession,
"test");
// start a new process instance
Message message = new
Message();
message.setMessage("Hello
World");
message.setStatus(Message.HELLO);
ArrayList cmds = new
ArrayList();
ArrayList dataList = new
ArrayList();
dataList.add(message);
cmds.add(CommandFactory.newInsertElements(dataList));
cmds.add(CommandFactory.newStartProcess("com.sample.ruleflow"));
ksession.execute(CommandFactory.newBatchExecution(cmds));
logger.close();
When I run the rules, all I get is “Hello World” (no
“Goodbye cruel world”). It does work with a Stateful
Session using insert, startProcess, and fireAllRules, but
this is a test using the rule flows with CommandFactory
functionality, something we need
for an application we are developing.