[jboss-jira] [JBoss JIRA] Updated: (JBRULES-2275) Runtime addition of rules to an existing knowledgebase causes rules using 'accumulate' to stop firing as expected.

Mark Proctor (JIRA) jira-events at lists.jboss.org
Thu Jul 22 17:37:39 EDT 2010


     [ https://jira.jboss.org/browse/JBRULES-2275?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Proctor updated JBRULES-2275:
----------------------------------

    Fix Version/s: 5.1.0
                       (was: 5.1.0.CR1)


> 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/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: Edson Tirelli
>             Fix For: 5.1.0
>
>
> 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/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list