This is the DRL file (InitRules.drl):
package drools.bug;
import drools.bug.DroolsHelper;
rule "init ruleflow"
salience 100
when
then
System.err.println("init ruleflow fired...");
drools.getWorkingMemory().startProcess("RuleFlow");
end
rule "01009"
ruleflow-group "GeneralRules"
lock-on-active
when
then
System.err.println("rule 01009 fired...");
end
and this is the RF file (RuleFlow.rf):
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
type="RuleFlow" name="RuleFlowName" id="RuleFlow" package-name="drools.bug" version="0.1" >
<header>
</header>
<nodes>
<start id="1" name="Start" x="363" y="100" width="48" height="48" />
<end id="2" name="End" x="364" y="502" width="48" height="48" />
<ruleSet id="3" name="InitName" x="348" y="176" width="80" height="48" ruleFlowGroup="Init" />
<ruleSet id="4" name="General Rules Name" x="348" y="255" width="80" height="48" ruleFlowGroup="GeneralRules" />
</nodes>
<connections>
<connection from="4" to="2" />
<connection from="1" to="3" />
<connection from="3" to="4" />
</connections>
</process>
The ruleSet.xml file contains references to these two files:
<?xml version="1.0" encoding="UTF-8"?>
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation="http://drools.org/drools-5.0/change-set"
>
<add>
<resource source='classpath:InitRules.drl' type='DRL' />
<resource source='classpath:RuleFlow.rf' type='DRF' />
</add>
</change-set>
And here is the Java main method:
public static void main(String[] args) {
try
{
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
InputStream isRuleSet = DroolsBugExample.class.getResourceAsStream("/ruleSet.xml");
kbuilder.add(ResourceFactory.newInputStreamResource(isRuleSet), ResourceType.CHANGE_SET);
KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase();
kb.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatelessKnowledgeSession session = kb.newStatelessKnowledgeSession();
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(CommandFactory.newFireAllRules());
Command<?> batchCommand = CommandFactory.newBatchExecution( commands );
session.execute( batchCommand );
}
catch (Exception e)
{
e.printStackTrace();
}
}
Running with Drools 5.0.1, the rule "init ruleflow" starts (as expected) another rule ("01009"). However, if Drools 5.1.1 (or 5.1.0) is used, the rule "01009" will not be fired.