Development lifecycle
by Branham, Jeremy [HR]
I am planning a new Drools architecture, and looking for the best way to migrate Drools rules through a series of environments.
Our typical SDLC involves an initial DEV environment, then migrating to one of several TEST environments, then to an ORT environment, then finally to a PROD environment.
The question has been asked a couple times, looking through the mail archives, but I'm curious if there have been any recent changes that could improve the development lifecycle.
I've read we could just use the import/export function, or the following two options -
Mentions Jackrabbit
http://article.gmane.org/gmane.comp.java.drools.user/25097/match=producti...
Using the Rest interface
https://community.jboss.org/wiki/PublishDroolsartifactsfromaproductionenv...
Anything else, or any best practice for this?
Thanks!
Jeremy D. Branham
Technology Architect
Sprint University Performance Support
Fort Worth, TX | Tel: **DOTNET
Office: +1 (972) 405-2970| Mobile: +1 (817) 791-1627
________________________________
This e-mail may contain Sprint proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.
11 years, 10 months
Any form of "groub by" or "distinct" in accumulate/collect ?
by Ephemeris Lappis
Hello.
Perhaps that my question has few sense or none...
I've an object graph with say A, B and C.
A has one or many B, that has one or many C.
I can navigate through the relations between my objects in both direction.
For example, I can do fo any instance of C : c.b.a (or c.getB().getA())...
My initial input facts or only C objects, and I'd like to identify all the
distinct A instances, and insert them into my working memory, as they
participate to global rules.
I've been looking for some forms of accumulate or collect, but I've not
found a correct way to do it.
Some help ?
Thanks
Regards.
--
View this message in context: http://drools.46999.n3.nabble.com/Any-form-of-groub-by-or-distinct-in-acc...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Multiple threads for KieBuilder
by RichardAmbridge
Hi,
We have over 20000 rules in our drools implementation. In drools 5 we
could build multiple packages in different threads and then create a
Knowledge base joining all those packages together.
e.g.
Thread:
knowledgeB = KnowledgeBuilderFactory.newKnowledgeBuilder();
knowledgeB.add(ResourceFactory.newReaderResource(new
StringReader(sb.toString())), ResourceType.DRL);
Then in the main compiler, once all threads have finished
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase(conf);
for each thread:
knowledgeBase.addKnowledgePackages(thrds[t].getKnowledgeB().getKnowledgePackages());
I can't seem to find anyway to do that with the new KIE implementation.
What I would like to do is something like:
Thread:
Create sb to have lots of rules
KieServices kieServices = KieServices.Factory.get();
KieFileSystem kfs = kieServices.newKieFileSystem();
kfs.write("src/main/resources/rules.drl", sb.toString());
KieBuilder kieBuilder = kieServices.newKieBuilder(kfs);
kieBuilder.buildAll();
..check errors
KieContainer kieContainer =
kieServices.newKieContainer(kieBuilder.getKieModule().getReleaseId());
KieBase kieBase = kieContainer.newKieBase(kieBaseConfiguration);
In main compiling, create multiple threads, each with its own rule set.
Then when all threads completed, take all the kieBase objects and merge into
one base.
then KieSession ksession=mergedKieBase.newKieSession();
We compile our rules offline and then load into our running servers. The
compile server is a multicore server, but buildAll is single threaded.
Is this possible?
Many thanks for the support,
Ric
--
View this message in context: http://drools.46999.n3.nabble.com/Multiple-threads-for-KieBuilder-tp40294...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Not able to use <kbase includes="" /> in Kie Spring
by Ashish Nayyar
Hi,
I am trying to include a another kbase in KIE Spring project. This is the
configuration
*knowledge-services.xml*
<kie:kmodule id="kie-spring">
<kie:kbase name="kie-base"
*includes="rules1Package"*packages="au.org.nps.dsaas.rules" >
<kie:ksession name="ksession1" type="stateless" >
<kie:consoleLogger />
</kie:ksession>
</kie:kbase>
</kie:kmodule>
<bean id="kiePostProcessor"
class="org.kie.spring.KModuleBeanFactoryPostProcessor"/>
*kmodule.xml*
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase *name="rules1Package"* packages="au.org.nps.dsaas.rules1" >
<ksession name="ksession2" type="stateless" />
</kbase>
</kmodule>
My KIE modules are discovered and I can see following in the logs
09:59:36,642 DEBUG
[org.drools.compiler.kie.builder.impl.ClasspathKieProject] (ServerService
Thread Pool -- 91) Found and used pom.properties
META-INF/maven/au.org.nps.dsaas/rules-repository/pom.properties
09:59:36,645 DEBUG
[org.drools.compiler.kie.builder.impl.ClasspathKieProject] (ServerService
Thread Pool -- 91) Discovered classpath module
au.org.nps.dsaas:rules-repository:0.0.1-SNAPSHOT
But Spring context fails to load and I get the following errors:
09:59:39,547 ERROR [org.drools.compiler.kie.builder.impl.AbstractKieModule]
(ServerService Thread Pool -- 91) Unable to build KieBase, could not find
include: rules1Package
As per the official documentation (
http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/ch.kie....)
, I can use the includes property of KBASE tag provided in Spring KIE. I am
using kie spring 6.1.0 Beta
Any suggestions?
Thanks
Ashish
11 years, 10 months
Drools Planner: what if possible values of a PlanningVariable are dependent of another one?
by Willem van Asperen
Hi All,
I have a PlanningEntity that has several planning variables, say A and
B. Now, if A is O then B can be X or Y and when A is P then B can be Y or Z.
I see two routes:
* create a solution property that generates X, Y and Z as alternatives
for B and rely on the score rules to dismiss improper values,
depending on the value of A
* create an entity property that only generates the possible values
for B (i.e. X,Y for A=O and Y,Z for A=P)
What is the best route?
(Alternatively I do not use the constructionHeuristic and just start of
my solution with a randomly (but correct) generated solution)
Regards,
Willem
11 years, 10 months
Restrict size/resource usage of drools session
by kurrent93
Hi
We have an application where users write their own rules via a UI, and these
are then translated into drl, and run in a dedicated drools session. Each
user can have one or more sessions.
However, there are times when something goes wrong - say a rule starts
looping - and it consumes all the resources - the server is running at 100%
cpu, and it then effects all users.
I realize we can optimize the the generated rules to prevent such issues,
and we are working on this - however am interested to know if there are any
ways - such as somehow sandboxing / restricting the resources that a drools
session can use, so that should a rule cause problems, it will not effect
the other running drools sessions.
Thanks for any advice on this problem.
--
View this message in context: http://drools.46999.n3.nabble.com/Restrict-size-resource-usage-of-drools-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Drools 6.0.1 Negative Patterns in Stream Mode not working
by RichardAmbridge
I am using drools 6.0.1 and I have the following test.
public class DroolsTest {
public DroolsTest() {
}
@Test
public void work() throws InterruptedException, IOException,
ClassNotFoundException {
StringBuilder sb = new StringBuilder();
sb.append("package drools\n");
sb.append("import drools.MyObject;\n\n");
sb.append("declare MyObject\n"
+ " @role ( event )\n"
+ "end\n\n");
sb.append("rule \"Template2\"\n"
+ "\n"
+ "salience 0\n"
+ "dialect \"mvel\"\n"
+ "when\n"
+ " $s : MyObject(val==0)\n"
+ " not( MyObject(val==1, this after [0s,5s] $s ) )\n"
+ "\n"
+ "then\n"
+ " System.out.println(\"Template 2 fired\")\n"
+ " $s.name=\"2\";\n"
+ "\n"
+ "end\n");
KieServices kieServices = KieServices.Factory.get();
KieFileSystem kfs = kieServices.newKieFileSystem();
kfs.write("src/main/resources/rules.drl", sb.toString());
KieBuilder kieBuilder = kieServices.newKieBuilder(kfs);
kieBuilder.buildAll();
Results results = kieBuilder.getResults();
assertFalse(results.hasMessages(Message.Level.ERROR));
if (results.hasMessages(Message.Level.WARNING)) {
System.out.println("Warnings logged");
}
KieContainer kieContainer =
kieServices.newKieContainer(kieBuilder.getKieModule().getReleaseId());
KieBaseConfiguration kieBaseConfiguration =
kieServices.newKieBaseConfiguration();
kieBaseConfiguration.setOption(EventProcessingOption.STREAM);
KieBase kieBase = kieContainer.newKieBase(kieBaseConfiguration);
KieSession ksession = kieBase.newKieSession();
MyObject one = new MyObject();
one.val = 0;
FactHandle fh1 = ksession.insert(one);
System.out.println("Insert one");
ksession.fireAllRules();
for (int i = 0; i < 13; i++) {
System.out.println("Sleep:" + i);
Thread.sleep(1000);
//After 5 seconds, rule should fire
}
assertEquals("2", one.name);
System.out.println("End");
ksession.halt();
ksession.dispose();
}
public class MyObject implements Serializable {
String name;
int val;
boolean fired;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getVal() {
return val;
}
public void setVal(int val) {
this.val = val;
}
public boolean isFired() {
return fired;
}
public void setFired(boolean fired) {
this.fired = fired;
}
}
}
The rule is using
+ " $s : MyObject(val==0)\n"
+ " not( MyObject(val==1, this after [0s,5s] $s ) )\n"
So, if a MyObject with val==0 is inserted, then after 5 seconds no MyObject
with val==1 is found the rule will fire.
This works in Drools 5.5.0
In 6.0.1 the rule doesn't fire.
Please help. I want to use drools 6 but cannot with this problem.
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-0-1-Negative-Patterns-in-Strea...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Drools eclipse plugin problem
by raojinghai@gmail.com
Hi,
Whenever I use classes from any third party jar files (not in JRE System
Library and Drools Library), I got error messages in Eclipse IDE. At the
place where I import the class, the error message is "Only a type can be
imported. ... resolves to a package". At the place where I use the class,
the error message is "... cannot be resolved to a type".
However, I have included the jar file in classpath. The project can be
executed successfully in Eclipse even with the error message in IDE.
To make the problem easier to describe and to reproduce if anybody
interested, I use the example reported at
https://issues.jboss.org/browse/DROOLS-373. Both my problem and this are
about external libraries, so I feel they may have some connections.
Below are my steps:
1. Download drools6scratch-kiemavenclasspath.zip from jira and unzip the
file
2. In eclipse, Import -> Existing Maven Projects, and select the unzipped
folder
3. After import, convert the project to Drools Project
Then I get errors in both package.drl and AppTest.java. The attached
screenshots can give more details.
This happens to every imported class from third party libraries. But the
classes from JRE System Libraries or Drools Libraries are fine.
So I have to disable drools builder, which also turns off drools validation
in eclipse. It is very inconvenient for my development work.
I believe many people are using eclipse for drools development, but I am
surprise nobody complains about it on Internet. First I suspect its
configuration problem on my side, but I tried with fresh installation on
both MacOS and windows 7, and I always get the same problem.
Below is my environment:
- OS: Mac OS X 10.9.2 and Windows 7
- Eclipse Kepler (Standard and for Java EE Developer)
- Drool Eclipse Plugin - JBoss Drools Core 6.0.1Final.
- Java SE 1.7
- Drools Runtime 6.0.1
Thank you so much if anybody can help.
Jinghai
11 years, 10 months
KieScanner not working
by Pykhtin, Alex
I'm trying to use KieScanner in 6.0.1.Final build and just can't make it work. Maybe it's actually an issue with my using of Maven.
Here's my code:
ReleaseId releaseId = ks.newReleaseId( "com.study", "project_jar", "0.0.1-SNAPSHOT" );
KieContainer kContainer = ks.newKieContainer( releaseId );
KieSession kSession = kContainer.newKieSession("ksession-rules_jar");
KieScanner kScanner = ks.newKieScanner( kContainer );
Where "com.study" is my fictional domain and "project_jar" is the jar of my project. It has dependency on "drools_jar" which is a kjar of version "0.0.1-SNAPSHOT" (same version for both jars, by the way).
Later, I'm trying to test drools_jar updating by doing two things:
1. Rebuilding and deploying drools_jar to the local repository;
2. Calling kScanner.scanNow()
And KieScanner is not picking up the changes.
If I'm deploying drools_jar with the same "0.0.1-SNAPSHOT" version, nothing happens, until the next time I restart my project.
If I'm deploying drools_jar with the new "0.0.2-SNAPSHOT" version, then it's not a correct dependency and KieScanner is not picking it up (as I expected).
If I'm rebuilding project_jar with a new dependency on "0.0.2-SNAPSHOT" of drools_jar, KieScanner is not picking it up either, but restart helps (as I expected).
What is the proper practice of using KieScanner?
Thanks,
Alex
11 years, 10 months
Drools 6.0.0 activation-group + salience bug or feature?
by Jan Šťastný
Hi,
I came across in my view strange behaviour of rules defined with
activation-group and salience. I use this combination to set the
priority of exclusively fired rules "Democracy City Tiles Production"
and "Basic City Tiles Production".
Their definitions:
rule "Democracy City Tiles Production"
dialect "mvel"
ruleflow-group "manageProductions"
activation-group "cityProduction"
salience 5
when
PlayerDTO($owner:id, government=="democracy")
$city:CityDTO(
owner==$owner
,$cityId:id
,$managedTiles:managedTiles
)
accumulate(
TileDTO (
id memberOf $managedTiles
,$foodProd:foodProduction
,$resourcesProd:resourcesProduction
,$tradeProd:tradeProduction
)
@watch(foodProduction,resourcesProduction,tradeProduction)
,$sumFood : sum($foodProd)
,$sumResources : sum($resourcesProd)
,$sumTrade :
sum(($tradeProd<1)?$tradeProd:($tradeProd+1))
)
UpdateCityProduction(cityId==$cityId)
then
modify($city){
setFoodProduction($sumFood)
,setResourcesProduction($sumResources)
,setTradeProduction($sumTrade)
}
end
and
rule "Basic City Tiles Production"
dialect "mvel"
ruleflow-group "manageProductions"
activation-group "cityProduction"
when
PlayerDTO($owner:id)
$city:CityDTO(
owner==$owner
,$cityId:id
,$managedTiles:managedTiles
)
accumulate(
TileDTO (
id memberOf $managedTiles
,$foodProd:foodProduction
,$resourcesProd:resourcesProduction
,$tradeProd:tradeProduction
)
@watch(foodProduction,resourcesProduction,tradeProduction)
,$sumFood : sum($foodProd)
,$sumResources : sum($resourcesProd)
,$sumTrade : sum($tradeProd)
)
UpdateCityProduction(cityId==$cityId)
then
modify($city){
setFoodProduction($sumFood)
,setResourcesProduction($sumResources)
,setTradeProduction($sumTrade)
}
end
But problem occurs when two CityDTO objects are in the session. I would
like to fire one rule for each CityDTO, but the activation-group cancels
all the activations after first is fired. So only one activation in
place of two fires. Here is the log:
==>[BeforeActivationFiredEvent: getActivation()=[[ Democracy City Tiles
Production active=false ] [ [fact
0:12:36803987:36803987:12:DEFAULT:NON_TRAIT:UpdateCityProduction(
cityId=5 )]
[fact
0:16:2083264739:2083264739:16:null:NON_TRAIT:[Ljava.lang.Object;@7c2c18e3]
[fact 0:11:792938926:966:11:DEFAULT:NON_TRAIT:CityDTO [id=5,
name=marefy, cityCentre=null, owner=1, improvements=[],
currentImprovement=null, enabledImprovements=[], homeUnits=[],
currentUnit=null, enabledUnitTypes=[], tradeRoutes=[], managedTiles=[1,
2], size=5, weLoveDay=false, disorder=false, foodProduction=0,
foodConsumption=0, foodSurplus=0, foodStock=0, resourcesProduction=0,
resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
researchAmount=0, peopleHappy=2, peopleUnhappy=1, peopleContent=1,
peopleEntertainers=0, peopleTaxmen=1, peopleScientists=0,
pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
[fact 0:9:1762763035:99463566:9:DEFAULT:NON_TRAIT:PlayerDTO [id=1,
name=honza, government=democracy, enabledGovernments=null,
currentAdvance=null, advances=null, enabledAdvances=null, treasury=0,
research=0, researchSpent=null, turnsAvailable=null, luxuriesRatio=0,
taxesRatio=0, researchRatio=0]] ] ],
getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl@6a5b07f2]
==>[ActivationCancelledEvent: getCause()=CLEAR, getActivation()=[[ Basic
City Tiles Production active=false ] [ [fact
0:15:807492131:807492131:15:null:NON_TRAIT:[Ljava.lang.Object;@30215a23]
[fact 0:11:792938926:966:11:DEFAULT:NON_TRAIT:CityDTO [id=5,
name=marefy, cityCentre=null, owner=1, improvements=[],
currentImprovement=null, enabledImprovements=[], homeUnits=[],
currentUnit=null, enabledUnitTypes=[], tradeRoutes=[], managedTiles=[1,
2], size=5, weLoveDay=false, disorder=false, foodProduction=0,
foodConsumption=0, foodSurplus=0, foodStock=0, resourcesProduction=0,
resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
researchAmount=0, peopleHappy=2, peopleUnhappy=1, peopleContent=1,
peopleEntertainers=0, peopleTaxmen=1, peopleScientists=0,
pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
[fact 0:12:36803987:36803987:12:DEFAULT:NON_TRAIT:UpdateCityProduction(
cityId=5 )] ] ],
getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl@6a5b07f2]
==>[ActivationCancelledEvent: getCause()=CLEAR, getActivation()=[[ Basic
City Tiles Production active=false ] [ [fact
0:23:833001332:833001332:23:null:NON_TRAIT:[Ljava.lang.Object;@31a69774]
[fact 0:18:1816369501:968:18:DEFAULT:NON_TRAIT:CityDTO [id=7, name=Brno,
cityCentre=null, owner=1, improvements=[], currentImprovement=null,
enabledImprovements=[], homeUnits=[], currentUnit=null,
enabledUnitTypes=[], tradeRoutes=[], managedTiles=[3, 4], size=1,
weLoveDay=false, disorder=false, foodProduction=0, foodConsumption=0,
foodSurplus=0, foodStock=0, resourcesProduction=0,
resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
researchAmount=0, peopleHappy=0, peopleUnhappy=0, peopleContent=1,
peopleEntertainers=0, peopleTaxmen=0, peopleScientists=0,
pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
[fact
0:20:1314789527:1314789527:20:DEFAULT:NON_TRAIT:UpdateCityProduction(
cityId=7 )] ] ],
getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl@6a5b07f2]
==>[ActivationCancelledEvent: getCause()=CLEAR, getActivation()=[[
Democracy City Tiles Production active=false ] [ [fact
0:20:1314789527:1314789527:20:DEFAULT:NON_TRAIT:UpdateCityProduction(
cityId=7 )]
[fact
0:19:1857434733:1857434733:19:null:NON_TRAIT:[Ljava.lang.Object;@6eb6346d]
[fact 0:18:1816369501:968:18:DEFAULT:NON_TRAIT:CityDTO [id=7, name=Brno,
cityCentre=null, owner=1, improvements=[], currentImprovement=null,
enabledImprovements=[], homeUnits=[], currentUnit=null,
enabledUnitTypes=[], tradeRoutes=[], managedTiles=[3, 4], size=1,
weLoveDay=false, disorder=false, foodProduction=0, foodConsumption=0,
foodSurplus=0, foodStock=0, resourcesProduction=0,
resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
researchAmount=0, peopleHappy=0, peopleUnhappy=0, peopleContent=1,
peopleEntertainers=0, peopleTaxmen=0, peopleScientists=0,
pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
[fact 0:9:1762763035:99463566:9:DEFAULT:NON_TRAIT:PlayerDTO [id=1,
name=honza, government=democracy, enabledGovernments=null,
currentAdvance=null, advances=null, enabledAdvances=null, treasury=0,
research=0, researchSpent=null, turnsAvailable=null, luxuriesRatio=0,
taxesRatio=0, researchRatio=0]] ] ],
getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl@6a5b07f2]
Is it a bug?
Thanks
Jan
11 years, 10 months