简体   繁体   English

Java 8,Drools 5.x和Drools 7.x

[英]Java 8, Drools 5.x and Drools 7.x

I am using Drools 5.x (drools-compiler 5.2.1.Final, drools-decisiontables 5.4.0.Final, and drools-templates 5.4.0.Final; jbpm-flow 5.1.1.Final, jbpm-bmpn2 5.1.1.Final and with their respective dependencies) for my Java job, I build/run it with Java 1.7.0_21. 我正在使用Drools 5.x(drools-compiler 5.2.1.Final,drools-decisiontables 5.4.0.Final和drools-templates 5.4.0.Final; jbpm-flow 5.1.1.Final,jbpm-bmpn2 5.1。 1.Final(以及它们各自的依赖性)针对我的Java作业,我使用Java 1.7.0_21来构建/运行它。 My current set up works properly. 我当前的设置正常运行。 I am using a decision table (spreadsheet). 我正在使用决策表(电子表格)。

I am able to build/run my project with Java 1.8.0_162 using drools 5.x as described above; 如上所述,我能够使用drools 5.x使用Java 1.8.0_162构建/运行我的项目; however, when the java job runs it loads the decision table (spreadsheet) but it does not fire up any of the rules, I am not getting an exception in the last line that gets executed: 但是,当Java作业运行时,它会加载决策表(电子表格),但不会触发任何规则,因此在执行的最后一行中没有出现异常:

Properties props = new Properties();

KnowledgeBuilderConfiguration configuration = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(props);

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newDecisionTableConfiguration(configuration);

DecisionTableConfiguration config = KnowledgeBuilderFactory.newDecisionTableConfiguration();

config.setInputType(DecisionTableInputType.XLS);

kbuilder.add(ResourceFactory.newClassPathResource(spreadsheetFile), ResourcType.DTABLE, config);  // last line executed and then job exists and completes successfully.

Prior to the last line getting executed I put some debug logs and they show the following: 在执行最后一行之前,我放置了一些调试日志,它们显示以下内容:

Properties (props): {} 属性(道具):{}

KnowledgeBuilderConfiguration (configuration): org.drools.compiler.PackageBuilderConfiguration@630cb4a4 KnowledgeBuilderConfiguration(配置):org.drools.compiler.PackageBuilderConfiguration@630cb4a4

KnowledgeBuilder (kbuilder): org.drools.builder.impl.KnowledgeBuilderImpl@239bof9d KnowledgeBuilder(kbuilder):org.drools.builder.impl.KnowledgeBuilderImpl@239bof9d

ResourceFactory.newClassPathResource(spreadsheetFile): [ClassPathResource path='spreadsheet.xls'] ResourceFactory.newClassPathResource(spreadsheetFile):[ClassPathResource path ='spreadsheet.xls']

ResourceType.DTABLE: ResourceType = 'Decision Table' ResourceType.DTABLE:ResourceType ='决策表'

DecisionTableConfiguration (config): org.drools.builder.conf.impl.DecisionTableConfigurationImpl@150ab4ed DecisionTableConfiguration(config):org.drools.builder.conf.impl.DecisionTableConfigurationImpl@150ab4ed

DecisionTableConfiguration (config.getInputType()): XLS DecisionTableConfiguration(config.getInputType()):XLS

So I decided to upgrade from drools 5.5.0 to 7.5.0 and use kie-api/kie-ci; 所以我决定从Drools 5.5.0升级到7.5.0并使用kie-api / kie-ci; I had to do some refactoring because now drools is part of the KIE (Knowledge Is Everything) umbrella, see the code below: 我必须进行一些重构,因为现在流口水是KIE(知识就是一切)保护伞的一部分,请参见下面的代码:

KieServices ks = KieServices.Factory.get();
KieContainer kc = ks.getKieClasspathContainer();
KieSession ks = kc.newKieSession("ksession-dtables");  //stateful session
FactHandle fh = ks.insert(fact);
ks.fireAllRules();

.... ....

The packages and rules are loaded into the Knowledge Base but only the first rules fire up and then it stops, do I need to upgrade my decision table (spreadsheet) in order to work for drools 7.5.0 with Java 8? 这些程序包和规则已加载到知识库中,但是只有第一个规则启动后才停止,我是否需要升级决策表(电子表格)才能在Java 8的drools 7.5.0中使用?

Any suggestions are welcome. 欢迎任何建议。

Thanks!! 谢谢!!

我开始使用Drools 6.5.0,现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM