drools

Drools 7.15.0 docker容器方式部署

烈酒焚心 提交于 2019-12-14 00:12:00
关于drools的相关介绍就不再赘述了,关于drools网上的资料都很少,或者都有些老了,最近折腾了一下,记录下安装部署的过程,希望能节省下大家的时间。 一、快速部署 1.拉取基础镜像,命令如下: docker run -p 8080:8080 -p 8001:8001 -d --name drools-workbench jboss/drools-workbench-showcase:7.15.0.Final docker run -p 8180:8080 -d --name kie-server --link drools-workbench:kie_wb jboss/kie-server-showcase:7.15.0.Final 2. 点击访问 ,账号密码:admin/admin 二、问题 1.drools中文规则乱码问题 由于我使用的是7.15.0版本,dockerfile中默认添加了JVM的文件编码格式 -Dfile.encoding=UTF-8 ,所以没有此问题了。 2.容器时区问题 由于docker中默认是零时区,需要在dockerfile中设置容器的时区,内容如下 RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone

Drools规则引擎详解-常用的drl实例

本秂侑毒 提交于 2019-12-13 19:18:29
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> package droolsDemo //说明:每个 drl 都必须声明一个包名,这个包名与 Java 里面的不同,它不需要与文件夹的层次结构一致, //主要用于可以根据kmodule.xml中不同的package属性来指定加载哪个.drl文件, //packages="org.some.pkg"表示ksession2只会加载org.some.pkg下的规则文件,如果没写,则默认加载所有的规则文件。 //导入实体类 import com.qianxin.rulesengine.drools.User import com.qianxin.rulesengine.drools.Pet import com.qianxin.rulesengine.drools.Dog import com.qianxin.rulesengine.drools.BoolTest rule "multiple condition" // salience值越大越先匹配 salience 1 when //多个条件测试:user中age在15-30 60-90之间并且 根据user的pet属性的color来处理不同的逻辑, $user : User((age>15 && age<30)||(age>60 && age<90)) $pet

Can KieContainer load multiple packages? and what's the relationship between KieContainer and KieBase

我的未来我决定 提交于 2019-12-13 17:33:01
问题 I'm new to drools. The project has several Kjars which are built from Kie workbench. And in our program, we want to put all these Kjars into one KieContainer. But I can see from the document is when creating KieContainer, it need a releaseId as parameter. The parameter is GroupId/ArtifactId/version of the Kjar, meaning, the KieContainer is related to only 1 Kjar. So how can I load these Jars to only one KieContainer? or it is impossbile to load several Kjars into one container? Another

Get list of facts from rule

柔情痞子 提交于 2019-12-13 10:38:22
问题 Suppose I have 1000 rules in drool and 20 customers. I want to fire those rules which are specific to a customer. It is possible that one rule is applicable for more than on customer. I know which customer is using the application so based on that I want to get list of rules applicable for the customer and list of the facts I need to get from the db to fire those rules. After getting both lists first I'll get the values from db and than fire all the rules for that particular customer. 回答1:

Drools rule does't working in Spring Boot Controller but working in Junit Test

那年仲夏 提交于 2019-12-13 07:58:39
问题 On my first day to learn drools.I got this weird problem. rule " Hello World " in drl cannot run in Controller,but working well in Junit test case. rule " Another rule " always run on both Controller and Junit test. the code in controller and junit test are same totally. Anyone who have idea is welcome. thanks . Sample.drl: package com.happylifeplat.checkin import com.happylifeplat.checkin.managerorder.beans.RaBean1; rule "Hello World" when $h : RaBean1( id == 1) then $h.setContent("from drl

Memory leak issue in Kie Session Drools 6.1.X

最后都变了- 提交于 2019-12-13 07:39:19
问题 I am using state full KieSession in drools 6.1.X. I observed following behaviors about memory usage by KieSession : In normal load test, it is working fine and avg. processing time is ok. I am also retracting all the inserted fact except some fact that is required always in the session. However, memory usage is increasing sequentially. We guess that this is due to the fact that KieSession is still holding information about inserted facts. Moreover, we are doing insertion and retraction on

Handling Exceptions in Drools Files

你说的曾经没有我的故事 提交于 2019-12-13 07:16:28
问题 How do we handle exceptions in Drools files? Example: My rule uses a shared Java method. rule "002.17.1" dialect "mvel" when comp : Component() then boolean validstate = SharedCodeUtil.hasValidateStateCountryUS(comp.address); errors.add(new ValidationFailure("002.17.1", comp.getSubApplicationGroupID(), comp.getSubApplicationID(),tokens)); end Java method SharedCodeUtil, may have exceptions: if (m != null) { try { Object o = m.invoke(form,(Object[])null); if(BudgetType.Project.equals(o)) count

Drools: modify() or update() only if exists, otherwise add

こ雲淡風輕ζ 提交于 2019-12-13 06:22:24
问题 This is my rule: rule "Set value of LeftArm fluent" when $ev: Start() $fl:LeftArm() then Sample s = new Sample(); s.setFluent($fl); s.setValue(-1.0); insert(s); end Ok, but if I want to set the value of the sample only if I haven't Samples with the same $fl AND otherwise modify the value of Sample, how can I do it? Am I obliged to write 2 rules? 回答1: No, you just add the condition that should inhibit the insertion of a new sample: rule "Set value of LeftArm fluent" when $ev: Start() $fl

Where can I see if a pattern failed in rule?

一曲冷凌霜 提交于 2019-12-13 04:36:09
问题 I run a rule that contains a few patterns, I want to know which pattern failed: I've tried to debug the code (drools 7.18.0), and didn't found the relevant place. rule example: rule "Trigger" agenda-group "Trigger" salience 100 when $pcase : PCaseMgr() D1($id: id, type != null, type == "AAA") D2(aId == $id) then $pcase.printAnalyticsRuleLog(">>>>>>>>>>>>>>>>>>> In Trigger"); end in the example above, if D1 pattern is passed, and D2 pattern is failed, where in the code (of drools 7.18.0) can i

Throwing exception in Guvnor (Guided Editor Rule)

▼魔方 西西 提交于 2019-12-13 03:59:55
问题 I'm building a rules project using Guvnor. In one of my DSL, I've the follow "consequence" statement for wrong operations: [when]Error "{message}"=throw new Exception( "{message}" ); If I use the DSL rule, writing all the rule with DSL sentences, it works perfectly. However, using the Guided Editor, this doesn't work and the validation says anything like that: [Error: unable to resolve method using strict-mode: org.drools.spi.KnowledgeHelper.throw()] [Near : {... throw new Exception( " ...