[jboss-jira] [JBoss JIRA] Created: (JBRULES-2275) Runtime addition of rules to an existing knowledgebase causes rules using 'accumulate' to stop firing as expected.
Justin King (JIRA)
jira-events at lists.jboss.org
Wed Sep 9 22:23:24 EDT 2009
Runtime addition of rules to an existing knowledgebase causes rules using 'accumulate' to stop firing as expected.
------------------------------------------------------------------------------------------------------------------
Key: JBRULES-2275
URL: https://jira.jboss.org/jira/browse/JBRULES-2275
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Affects Versions: 5.0.1.FINAL
Environment: Windows XP SP3. Java 1.5, Eclipse Ganymede
Reporter: Justin King
Assignee: Mark Proctor
Using accumulate, we have a rule which looks like the following:
rule "Term2Obligation1"
when
Number(intValue > 0) from accumulate(
$res : TermExecutedEvent(term == "standardStockResponse")
$req : TermExecutedEvent(term == "standardStockQuery",
correlationId == $res.correlationId,
this before[5s] $res),
init(int total = 0;),
action(total++;),
result(new Integer(total)))
then
System.out.println("Term2Obligation1");
end
This rule executes correctly as expected. However Sometimes we wish to add new rules to the existing KnowledgeBase (originally read in from .drl file) at runtime. To do this we use the following method:
String rule = "rule \"GeneralClause-2\" " +
"when " +
"ObligationComplianceEvent(term == \"term2\", obligation == \"obligation1\", level == 2) " +
"then " +
"System.out.println(\"GeneralClause-2\");" +
"contract.setState(\"Hello\");" +
"end";
Resource ruleResource = ResourceFactory.newReaderResource((Reader) new StringReader(rule));
kbuilder.add(ruleResource, ResourceType.DRL);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
Doing this creates major problems and unpredictable behavior. Rules continue to fire after the runtime addition but any rules using accumulate in the above described fashion will no longer execute, even though the conditions are entirely unrelated to the new rule that has been added. However the rule will continue to execute as expected if one of the conditions is moved outside of the accumulate as per the following:
rule "Term2Obligation1"
when
$res : TermExecutedEvent(term == "standardStockResponse")
Number(intValue > 0) from accumulate(
$req : TermExecutedEvent(term == "standardStockQuery",
correlationId == $res.correlationId,
this before[5s] $res),
init(int total = 0;),
action(total++;),
result(new Integer(total)))
then
System.out.println("Term2Obligation1");
end
It seems that adding new rules at runtime somehow creates a problem which prevents rules using accumulate firing. Or at least rules with more than condition inside the accumulate. This would appear to be a definite bug, perhaps related to http://lists.jboss.org/pipermail/rules-users/2007-August/002696.html
This is preventing us from continuing our project as we needs to know all rules will continue to work as expected even after runtime additions. Please help! :)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list