Loading rules from the filesystem?
by Leonard93
Can anyone here give me a good documentation place or thingy where I can read
about how to implement the drools 6 method of loading your rules from a
folder in the file system instead of inside the jar.
I have it working currently with the knowledgebase class, but since that is
deprecated I want to use the new classes. Although I read the drools
documentation about KieBase and such and programmatically defining your
kmodule. I did not really understand how that will help me load my rules
from a folder.
Basically what I want is that the rules located in C:\RulesFolder\rules.drl
will be loaded into my application and available within a stateless session.
Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/Loading-rules-from-the-filesystem-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 11 months
KnowledgeBase caching
by krzysztofcislo
Hi,
In our project we would like to cache KnowledgeBase once it's created
because compilation of rules takes long time and we can't afford to do it
every time we need to process rules.
Generaly we use ehCache as caching mechanism, but I am not sure if it's the
best way to just put KnowledgeBase instance there. KnowledgeBase can have
many inner objects and total size calculation is not efficient (ehCache
complains about it). Setting count limit to cache object, and not memory
limit can lead to out of memory or at least application performance
degradation.
Did anyone try to cache this object and reuse it further?
Thank you in advance for answers.
--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeBase-caching-tp4029276.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 11 months
java.lang.VerifyError: Bad type on operand stack
by lvtenorio
Hello,
I am writing a rules file and unit tests to test each one of them. I am
getting this error during the execution
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
ConditionEvaluator81806ffb7242407db6e6d8f829f4fd4d.evaluate(Lorg/drools/core/common/InternalFactHandle;Lorg/drools/core/common/InternalWorkingMemory;Lorg/dr
ools/core/reteoo/LeftTuple;)Z @12: ireturn
Reason:
Type 'java/lang/Boolean' (current frame, stack[0]) is not assignable to
integer
Current Frame:
bci: @12
flags: { }
locals: { 'ConditionEvaluator81806ffb7242407db6e6d8f829f4fd4d',
'org/drools/core/common/InternalFactHandle',
'org/drools/core/common/InternalWorkingMemory',
'org/drools/core/reteoo/LeftTuple' }
stack: { 'java/lang/Boolean' }
Bytecode:
0000000: 2bb9 001b 0100 c000 1db6 0021 ac
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
at java.lang.Class.getConstructor0(Class.java:2803)
at java.lang.Class.getConstructor(Class.java:1718)
at
org.drools.core.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:197)
at
org.drools.core.rule.constraint.ASMConditionEvaluatorJitter.jitEvaluator(ASMConditionEvaluatorJitter.java:55)
at
org.drools.core.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:289)
at
org.drools.core.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:53)
at
org.drools.core.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
The tests don't stop running and keep working. Here is my pom in case it
helps
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DroolsTest</groupId>
<artifactId>DroolsTest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.8-01</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>6.1.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>6.1.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>6.1.0.Beta1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.6</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
<printSummary>true</printSummary>
<reportFormat>plain</reportFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.9</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.17</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
</project>
I am using IntelliJ IDEA13.0.2
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-VerifyError-Bad-type-on-opera...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 11 months
Free Form DRL through BRL in guided decision table
by Joe White
Does the workbench extended entry guided decision table support this kind of syntax:
ServiceLineStatusInfo( claimStatusCodes contains "$param" )
Where $param is replaced with the value of the column? When I add that through New Column->Add a Condition BRL Fragment->Free Form DRL all I get is a checkbox column. Is there a way to set that up so that it allows entry and does the substitution?
I know the line above could be built easily in other ways. It is just an example to illustrate. I have some more complex logical constructs that I'd like to do in straight DRL fragments if possible.
Thanks,
Joe
11 years, 11 months
KnowledgeAgentImpl registeredResourceMap memory issue
by Cwen
We are seeing this HashMap (KnowledgeAgentImpl.registeredResourceMap) keeps
growing when a pkg is updated. It looks like creating more
CompositeClassLoader and not removing the old rule references. So it causes
KnowledgeAgentImpl use large memory. We are using 5.5.0.final.I am attaching
an image from memory analyzer to show how the HashMap holds up multiple
CompositeClassLoader and they are using about 230MB of memory. It increases
when the pkg gets updated with about 150 rules.
--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeAgentImpl-registeredResourceMa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 11 months
Drools causes switch(enum e) to break?
by Leonard93
So I have a really weird problem and I think it could be relate-able to
Drools, or maybe not but maybe some people here have seen it before.
I have a simple enum called 'RuleTypes' which is defined in its own file.
I have somewhere in my class a switch statement where I use the enum like
this:
(The method is not finished, but its enough to show the problem)
public IResult EvaluateRule(Object obj, RuleType type)
{
//TODO
switch(type)
{
case Discount :
TripRequest lr = (TripRequest) obj;
_Session.execute(lr);
return lr.getResult();
case Content:
break;
case None:
break;
default:
break;
}
return null;
}
But I get an error saying 'Cannot switch on a value of type RuleType. Only
convertible int values or enum variables are permitted'. While RuleType an
enum is 100% sure.
Yet if I make a new project (with no drools libraries), make the same
RuleType enum in its own file and have an empty class doing:
public Test(RuleType type)
{
switch(type)
{
case Discount :
break;
case Content:
break;
case None:
break;
default:
break;
}
}
There are no compiler errors. Anyone know here what could possibly happen?
The only thing I could find was a possible Eclipse bug but that one had a
fix that does not work for me (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=413368 ).
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 11 months
how KnowledgeAgent to use guvnor cluster?
by 窦晓峰
Hello, every one:
I am newbie for drools and guvnor, so excuse me if the question is
duplicated for others.
I am use guvnor 5.5.0 final and set up two nodes guvnor cluster
successfully. But I don’t know how to configure the knowledge agent to use
the cluster for HA?(before the cluster set up a nginx for banlance?)
Thx a lot
11 years, 11 months
Pooling stateful sessions to have threaded executions of a ruleset
by Maxime Falaize
Hello,
I want to ask you if it is a good practive to pool stateful sessions for a
specific ruleset to improve the execution performance.
Actually in my application I execute my rules by calling SOAP webservice.
For performance purpose, I test multithreaded calls to my webservice and I
noted that when I pool sessions in the server side, it improves the
performance a lot.
To pool sessions, I just declare multiple ksession tag in my kmodule.xml :
<kbase name="KBase" packages="com.example.*">
<ksession name="KSession1"/>
<ksession name="KSession2"/>
<ksession name="KSession3"/>
<ksession name="KSession4"/>
<ksession name="KSession5"/>
</kbase>
In my spring webservice endpoint I just put that code to handle the pool :
@Endpoint
public class ExampleEndpoint implements InitializingBean {
@Autowired
private ExampleRuleService ruleService;
private Map<Integer, Boolean> isRunningMap = new HashMap<Integer,
Boolean>();
private static final int NB_POOL_SESSIONS = 5;
@PayloadRoot(localPart = "com.example.ExampleRequest")
@ResponsePayload
public ExampleResponse handleRequest(
@RequestPayload ExampleRequest request) throws
InterruptedException {
KieServices ks = KieServices.Factory.get();
KieContainer kc = ks.getKieClasspathContainer();
while (true) {
for (int i = 0; i < NB_POOL_SESSIONS; i++) {
boolean run = false;
synchronized (isRunningMap) {
if (!isRunningMap.get(i)) {
isRunningMap.put(i, true);
run = true;
}
}
if (run) {
KieSession ksession = kc.newKieSession("KSession" + (i
+ 1));
ExampleResponse response = ruleService.run(ksession,
request);
ksession.dispose();
isRunningMap.put(i, false);
return response;
}
}
Thread.sleep(100);
}
}
public void afterPropertiesSet() throws Exception {
for (int i = 1; i <= NB_POOL_SESSIONS; i++) {
isRunningMap.put((i - 1), false);
}
}
}
It works well because in my benchmark I improve 5 times the performance (as
I have 5 different threads) but I wondered if it is a good practice and if
it does not hide any issues that I could have in the future.
Thanks for your help.
--
Maxime FALAIZE
11 years, 11 months