[rules-users] Compiled rules differ KnowledgeAgent vs ResourceChangeScanner

lhorton LHorton at ABCLegal.com
Thu Jul 12 15:38:13 EDT 2012


I did some more research on this problem but am at a loss for an answer. I'd
appreciate any further ideas for troubleshooting.   

I added some code to my server to display the fields of one of the rules
that does not run until it is reloaded by the resource change scanner.  I
captured the field values before and after the reload of the drl file, and
compared the values of the fields.  The only field in which I can see a
change of value is loadOrder.

This test proved the rule is present in the knowledge base in in the
"before" case (i.e. the rule is there when first loaded, but it does not
fire).

I'm attaching the spreadsheet that compares the fields before (rule did not
fire) and after (rule file reloaded and rule does fire as expected).

This is the code I wrote to capture the field values using reflection.

for (KnowledgePackage knowledgePackage :
workflowKnowledgeBase.getKnowledgePackages()) {
	Class<?> clazz = RuleImpl.class;
	Field ruleField = clazz.getDeclaredField("rule");
	ruleField.setAccessible(true);
	for (Rule rule : knowledgePackage.getRules()) {
		System.out.println(rule.getPackageName() + " " + rule.getName() + " ");
		Rule innerRule = (Rule) ruleField.get(rule);
		Field[] fields = innerRule.getClass().getDeclaredFields();
		for (Field field : fields) {
			field.setAccessible(true);
			if (field.getType().isArray() && field.get(innerRule) != null) {
				String[] strs = (String[]) field.get(innerRule);
				StringBuffer buf = new StringBuffer();
http://drools.46999.n3.nabble.com/file/n4018640/rulesTest.xls rulesTest.xls 
				for (String s : strs) {
					buf.append(s);
					buf.append(" ");
				}
				System.out.println("," + field.getName() + "," +
field.getType().getSimpleName() + "," + field.getGenericType() + "," +
buf.toString());
			} else {
				System.out.println("," + field.getName() + "," +
field.getType().getSimpleName() + "," + field.getGenericType() + "," +
field.get(innerRule));
			}
		}
	}
}


--
View this message in context: http://drools.46999.n3.nabble.com/Compiled-rules-differ-KnowledgeAgent-vs-ResourceChangeScanner-tp4018608p4018640.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list