not matches
by RichardA
In drools5 I have taken the standard Eclipse demo project, and changed the
Sample.drl to contain only the following:
package com.sample
import com.sample.DroolsTest.Message;
rule "Hello World"
when
m : Message( message not matches "^TEST" )
then
System.out.println( "adding TEST to message" );
m.setMessage( "TEST set" );
update( m );
end
When I run this, drools gets into an infinite loop
This used to work in drools4.
Any ideas?
Thanks
--
View this message in context: http://n3.nabble.com/not-matches-tp92276p92276.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months
Drools 5.1.0.M1 - Retrieve return value of GenericCommand<T> from ExecutionResults
by Vijay K Pandey
Hi,
If I execute a GenericCommand<T> against the statefulknowledgesession it returns the ExecutionResults, but how do I retrieve the actual returned value of the GenericCommand which I had implemented.
Lets says something like this - so how do I get hold of the Boolean object return value from the command.
public class TestCommand implements GenericCommand<Boolean> {
public Boolean execute(Context context) {
return Boolean.TRUE;
}
}
I put a debug on and can see that ExecutionResultsImpl is returned but it has nothing inside?
What I am missing or doing something wrong?
Thanks
Vijay
14 years, 11 months
Drools KnowledgeBuilderImpl.add(...) not thread safe???
by Grigoriev, Grigoriy
I have already mentioned this issue previously here (see http://n3.nabble.com/Mvel-and-multithreading-td50133.html)
Maybe I have described the problem not detailed enough.
We are using Drools version 5.0.1 and have a concrete problem with it in our production environment. Our customer looks already interrogative at the developer team and have "questions" about drools... please help! :)
Let us assume a multithreaded application, that tries to initialise & start several processes using a StatefulKnowledgeSession in order to use in these processes rule flow. The flow in all the processes is the same but every process instance must have an own StatefulKnowledgeSession instance because of stateful session.
Actually the problem:
At the initializing phase occurs an org.mvel2.CompileException exception from time to time at KnowledgeBuilder.add(...):
Exception in thread "Thread-60" [Error: incomplete statement: (possible use of reserved keyword as identifier: )]
[Near : {... globals != empt ....}]
^
[Line: 0, Column: 0]
at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:153)
at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:44)
at org.mvel2.MVEL.eval(MVEL.java:514)
at org.mvel2.templates.res.IfNode.eval(IfNode.java:61)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.TerminalNode.eval(TerminalNode.java:39)
at org.mvel2.templates.res.ForEachNode.eval(ForEachNode.java:116)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.TerminalNode.eval(TerminalNode.java:39)
at org.mvel2.templates.res.IfNode.eval(IfNode.java:64)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.ExpressionNode.eval(ExpressionNode.java:53)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:195)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:190)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:180)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:169)
at org.drools.rule.builder.dialect.java.AbstractJavaRuleBuilder.generatTemplates(AbstractJavaRuleBuilder.java:126)
at org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:128)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:86)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1159)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:649)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at com.myfirm.RuleFlowProcess.init(RuleFlowProcess.java:25)
at com.myfirm.RuleFlowProcess.clone(RuleFlowProcess.java:53)
at com.myfirm.ThreadTest$CloneThread.run(ThreadTest.java:35)
Caused by: java.lang.NullPointerException
at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:113)
... 27 more
Exception in thread "Thread-72" [Error: incomplete statement: (possible use of reserved keyword as identifier: )]
[Near : {... declarations != empt ....}]
^
[Line: 0, Column: 0]
at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:153)
at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:44)
at org.mvel2.MVEL.eval(MVEL.java:514)
at org.mvel2.templates.res.IfNode.eval(IfNode.java:61)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.ExpressionNode.eval(ExpressionNode.java:53)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.ExpressionNode.eval(ExpressionNode.java:53)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.TerminalNode.eval(TerminalNode.java:39)
at org.mvel2.templates.res.ForEachNode.eval(ForEachNode.java:116)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.TerminalNode.eval(TerminalNode.java:39)
at org.mvel2.templates.res.ForEachNode.eval(ForEachNode.java:116)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.ExpressionNode.eval(ExpressionNode.java:53)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.res.ExpressionNode.eval(ExpressionNode.java:53)
at org.mvel2.templates.res.TextNode.eval(TextNode.java:46)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:195)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:190)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:180)
at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:169)
at org.drools.rule.builder.dialect.java.AbstractJavaRuleBuilder.generatTemplates(AbstractJavaRuleBuilder.java:135)
at org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:128)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:86)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1159)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:649)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at com.myfirm.RuleFlowProcess.init(RuleFlowProcess.java:25)
at com.myfirm.RuleFlowProcess.clone(RuleFlowProcess.java:53)
at com.myfirm.ThreadTest$CloneThread.run(ThreadTest.java:35)
Caused by: java.lang.NullPointerException
at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:113)
... 33 more
To demonstrate this problem I have created a simple test maven project that reproduces this error (s. attach):
I have a class that creates & inits stateful knowledge session in a init method (RuleFlowProcess):
/**
* inits the rule flow
*/
public class RuleFlowProcess {
private StatefulKnowledgeSession ksession;
public void init() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("threadSafeTest.rf"), ResourceType.DRF);
kbuilder.add(ResourceFactory.newClassPathResource("testRules1.drl"), ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("testRules2.drl"), ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("testRules3.drl"), ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("testRules4.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
StringBuilder errorString = new StringBuilder();
for (KnowledgeBuilderError error : errors) {
errorString.append(error);
}
throw new RuntimeException(errorString.toString());
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
ksession = kbase.newStatefulKnowledgeSession();
}
...
}
I create & init concurrently in several (200) threads this RuleFlowProcess and some threads crash with this exceptions while adding the resources.
I have run this project on two PCs:
core 2 duo @ 2.6 ghz, win xp prof sp3, sun jdk 1.6.0_17
Pentium Dual CPU E2160 @ 1.8GHz, XP prof SP3, sun jdk 1.6.0_16.
Could you please help us to clear this problem? Are we doing here something wrong?
If it should be an drools error, could you please create an issue for it?
Thanks!
Wbr,
Grigoriy Grigoriev
14 years, 11 months
Problem when uploading a rule file with XOR into Guvnor
by ramram
Hi All,
I have a rule file (testProcess.rf) in this rule file I have the following
in the:
<split id="5" name="Gateway" x="329" y="160" width="49" height="49"
type="2" >
<constraints>
<constraint toNodeId="13" name="End Process" priority="2"
type="code" dialect="java" >return endProcess;</constraint>
<constraint toNodeId="3" name="Create User" priority="1" type="code"
dialect="java" >return createUser;</constraint>
</constraints>
</split>
When I remove the type and dialect the process could be uploaded with no
problems. But I need this in the process so what can be done?????
I have tried to use the process as a FLUENT API inside the console but I
have a problem:
How can I define the LOG as a fluent API. IS this correct:
factory
.workItemNode(3).name("Log")
.workName("Log")
.inMapping("index", "index")
.outMapping("createUser", "createUser")
.outMapping("index", "index")
.outMapping("endProcess", "endProcess")
.outMapping("user", "user").done()
I am having the following exception:
Exception in thread "main" java.lang.ClassCastException:
org.drools.workflow.core.node.ActionNode cannot be cast to
org.drools.workflow.core.node.WorkItemNode
at
org.drools.ruleflow.core.factory.WorkItemNodeFactory.getWorkItemNode(WorkItemNodeFactory.java:52)
at
org.drools.ruleflow.core.factory.WorkItemNodeFactory.workName(WorkItemNodeFactory.java:76)
at com.fp.scenarios.CreateProcess.createProcessRami(CreateProcess.java:183)
at com.fp.scenarios.CreateProcess.main(CreateProcess.java:30)
--
View this message in context: http://n3.nabble.com/Problem-when-uploading-a-rule-file-with-XOR-into-Guv...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months
Rule Reuse Best Practice
by Jason Davidson
Hello,
What is the best practice for reusing rules? I've got a license number
validation rule that I need to reuse for different fact types. For example,
the first rule uses the license number in a CitationDTO fact:
rule "Citation DL Number"
ruleflow-group "CitationEntryValidationFlow"
when
CitationDTO($dln :
citationSubject.driverLicense.driverAuthorizationId not matches "^.{5,15}$")
then
resultHolder.setMessage(GenericCitationFieldIds.DLN,"DLN [{0}] must
be at least 5 characters long and no more than 15 characters long.", new
Object[]{$dln});
end
Then I have another rule that uses the license number from the
InCourtSearchDTO:
rule "InCourt DL Number"
ruleflow-group "InCourtSearchValidationGroup"
when
InCourtSearchDTO( $d : dln not matches "^.{5,15}$")
then
resultHolder.setMessage(UserLogonFieldIds.END_DT,"DLN [{0}] must be
at least 5 characters long and no more than 15 characters long.", new
Object[]{$d});
end
Obviously this is a poor implementation because the license number check
'not matches "^.{5,15}$"' is duplicated. Is there a way I can reuse this
rule?
Thanks!
14 years, 11 months
Application Servers and Drools Flow???
by ramram
Hi All,
I am currently using the Drools Flow with the GWT web console and I could
create many rule flow processes using the JBOSS 4.2.3 version. But what I am
concerned about is that there will be problems if I changed the application
server? Please can you help me and tell me if the Drools Flow and GWT web
console are compatible with the following application servers:
1- OC4J
2- Bea Weblogic 9.0
3- IBM Websphere
4- Tomcat 6.0
--
View this message in context: http://n3.nabble.com/Application-Servers-and-Drools-Flow-tp91216p91216.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months
Drools Fusion deadlock?
by Paul R.
Hi,
I'm having a problem in my project; inserting large quantities of facts into
a StatefulKnowledgeSession (stream mode) causes my code to hang after a few
minutes of activity. I've attached a simple test to demonstrate the problem;
when I run the attached code ~ 20 objects get inserted into the session, the
rule fires once and then hangs. No more facts get inserted and the rule
never fires again.
Is there anything obvious wrong with the attached code, or is it possible
that this is a bug in drools [drools-5.0.1]?
Thanks and regards,
Paul
14 years, 11 months
confusing world of drools
by tim arnold
hello, i think they have made so powerful that it is to abstract to understand.
following: all i would like to do is magage a large number of rules under a set of "rule sets"
each rule set can have many rules
each rule can belong to one or multiple sets
or a many to many relationship.
i expect for a given rule set id, that the corresponding rules to be executed. i dont see yet how this is done in drools under the current documentation.
thank you for any help
14 years, 11 months
Best approach for inserting facts into Drools
by Matias
Hi, this is my first time with Drools and I would really appreciate if
someone can give me some advice on the following:
Scenario:
* There is a list of objects 'A' which is updated periodically (initially
every 1 min.)
* In the meantime I would like to run a set of 40 rules on 'A' to modify a
second list 'B'.
* 'A' may contain more than a thousand objects (its size might grow up to a
few thousands or shrink on every update – i.e. its size is not constant on
each update).
My question to the list is: “What is the best approach I should follow to
insert facts into Drools, i.e. To populate and update the ksession data ?”
Please see my questions in more detail below as Q1, Q2 and Q3.
In other words, which one of the two following approaches is recommended ?
1) Insert every single item from 'A' and 'B' into the ksession.
Q1: For the objects that changed inside, Do I need to notify Drools ? If
I do, I guess I'll need a fact-handler for each item on the list.
2) Insert the lists 'A' and 'B' in the session
Q2: 'A' is actually a TreeMap<String, Object>. Would it be more
convenient to insert it as a list ?
Q3) In terms of performance, which of the 2 approaches above is the best –
or shall I definitely avoid one ?
Thanks,
Matias
--
View this message in context: http://n3.nabble.com/Best-approach-for-inserting-facts-into-Drools-tp9047...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months