Can drools work in multithreaded environment?
by Barath
Hi,
While doing a load test with jmeter,my web service application with drools
works fine for few clients(5 simultaneous hits for 10 times)
but when i increase my clients(120 simultanious hits for 100 times) i am
gettin the following exception for
few client, (out of 12,000 hits 200 throws this exception)
problem encountered at node [11] 5{170,189}: unable to resolve property:
null pointer exception in property: declr.identifier
org.mvel.TemplateInterpreter.execute(TemplateInterpreter.java:528)
org.mvel.TemplateInterpreter.parse(TemplateInterpreter.java:341)
org.drools.rule.builder.dialect.java.AbstractJavaBuilder.generatTemplates(AbstractJavaBuilder.java:113)
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:95)
org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
com.drools.util.RuleEngine.applyRule(RuleEngine.java:47)
com.drools.util.DroolsController.getAdvertisement(DroolsController.java:94)
com.drools.util.DroolsController.routeBusinessMethod(DroolsController.java:67)
com.drools.util.DroolsController.getAdvertisement(DroolsController.java:43)
com.drools.MyEndpoint.getAdvertisement(MyEndpoint.java:237)
com.drools.MyEndpoint.process(MyEndpoint.java:144)
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:595)
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
java.lang.Thread.run(Thread.java:619)
drl file has 6 rules,
5 rules - which retract facts which passes the rule.
1 rule(low salience) - will add the fact to java.util.List (set as global)
which passes the rule.
1 . Am i getting this error bcoz of the global list? or any other reason?
2 . How to solve this problem?
here the rules,
<code>
global java.util.List feasibleAdv;
rule " percentage rule "
when
$adv : Advertisement( percentageLimit != 0 , percentageLimit <
playedPercentage )
then
System.out.println("remove this adv (failed percentage):
"+$adv.getAdvertisementID());
retract($adv);
end
rule "per day rule"
when
$adv : Advertisement( limitperday != 0 , limitperday <= playedperday
)
then
//System.out.println("remove this adv (failed day):
"+$adv.getAdvertisementID());
retract($adv);
end
rule "per week rule"
when
$adv : Advertisement( limitperweek != 0 , limitperweek <=
playedperweek)
then
//System.out.println("remove this adv (failed week):
"+$adv.getAdvertisementID());
retract($adv);
end
rule "per month rule"
when
$adv : Advertisement( limitpermonth != 0 , limitpermonth <=
playedpermonth)
then
//System.out.println("remove this adv (failed month) :
"+$adv.getAdvertisementID());
retract($adv);
end
rule "total played rule"
when
$adv : Advertisement( totallimit != 0 , totallimit <= totalplayed )
then
//System.out.println("remove this adv (failed total played) :
"+$adv.getAdvertisementID());
retract($adv);
end
rule "advertisement select rule"
salience -1
when
$adv : Advertisement( $playedPercentPerAdvertisement :
playedPercentPerAdvertisement)
not( Advertisement( playedPercentPerAdvertisement <
$playedPercentPerAdvertisement ) )
$advertisementCount : Integer()
then
boolean status = true;
if($advertisementCount-1 < 0){
//System.out.println("halted");
status = false;
drools.halt();
}
if(status){
feasibleAdv.add($adv);
drools.update(
drools.getWorkingMemory().getFactHandle($advertisementCount), new
Integer($advertisementCount-1) );
retract($adv);
}
end
</code>
--
View this message in context: http://www.nabble.com/Can-drools-work-in-multithreaded-environment--tp170...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 3 months
Re: Ruleflow-group attribute causing rule to not fire
by Roger Tanuatmadja
> From: "Roger Tanuatmadja" <rogerst(a)gmail.com>
> To: rules-users(a)lists.jboss.org
> Date: Mon, 19 May 2008 11:55:19 -0700
> Subject: Ruleflow-group attribute causing rule to not fire
> Hi,
>
> I am new to both rules engine and Drools. I am currently evaluating Drools
> 4.0.7 for use in our new project.
> Basically I have been writing a bunch of individual rules and things have
> been fine, the rules that I expected to fire were fired, etc, etc. I then
> proceeded to investigate rule flows. I started innocently enough i.e. adding
> the ruleflow-group attribute to some of my rules. I also defined a ruleflow
> mapping (.rfm).
>
> I then reran my unit-tests (WITHOUT reading the rules in as rule flows) and
> some of my rules were no longer firing!!. I added an Agenda Listener to my
> code and
> 1. without the ruleflow-group attribute, activations were created, and
> fired.
> 2. with the ruleflow-group attribute, activations were created but not
> fired.
>
> Using the debugger yielded the same logical outcomes i.e. without the
> ruleflow-group attribute, my breakpoints were hit, but with the attribute
> specified, none of my breakpoints were hit.
>
> My question is: Is this behavior expected? And why? Especially since some
> other rules (with the attribute specified) continued to work. I've read the
> documentations as much as possible, but I am really new to this field so I
> might not even know what questions to ask either.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Roger
>
>
>
>
16 years, 3 months
Rule exception
by Delaunay Gaetan
Hi all,
I've got problem with the following rule
rule 'Satellite mediation'
when
PricingField(name=="srv", eval(strValue.contains("VOIX")))
$field : PricingField( name == "duree")
then
mediationManager.addLine(11,$field.getIntValue());
end
I've got this exception when this rule is use
java.lang.AbstractMethodError:
Mediation.Rule_Satellite_mediation_0ReturnValue0Invoker.evaluate(Ljava/lang/Object;Lorg/drools/spi/Tuple;[Lorg/drools/rule/Declaration;[Lorg/drools/rule/Declaration;Lorg/drools/WorkingMemory;)Z
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:210)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:132)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:317)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:140)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:298)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
at org.drools.reteoo.Rete.assertObject(Rete.java:177)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:659)
What's wrong?
16 years, 4 months
issue with .drl file to .brl file conversion
by JigarP
Hi,
I am using below code to convert .brl to .drl. but i do not know that how
it will put import statement and package name in our new .drl file which we
define in rule.package file. which will be input for processing all rules.
Below is my code snippet.
String fileName = "SampleTest.brl";
File file = new File(fileName);
String fileAsString="";
fileAsString = FileUtils.readFileToString(file);
BRXMLPersistence read = (BRXMLPersistence) BRXMLPersistence.getInstance();
BRDRLPersistence write = (BRDRLPersistence)
BRDRLPersistence.getInstance();
String outputDRL = write.marshal(read.unmarshal(fileAsString));
System.out.println(outputDRL);
String packagefile = resolvePackageFile();
final PackageBuilder builder = new PackageBuilder();
try {
builder.addPackageFromDrl( new StringReader(packagefile),new
StringReader(fileName));
} catch (DroolsParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
I have below questions.
1) can we just write single rule using GUI Editor?(once it convert into .brl
file ) or we can write multiple rules in same file using brl.
2) How can we get actual .brl file from .drl file ( as it should have
import, package and lots of rules). what is the procedure to achieve this.
Please reply so we can get real usage of Drool GUI Rule plug-in.
Regards,
Jigar
--
View this message in context: http://www.nabble.com/issue-with-.drl-file-to-.brl-file-conversion-tp1868...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months
Reusing predicates
by Kris Nuttycombe
Hi, all,
I have a set of rules where the LHS is essentially the same except for
a couple of additional conditions in each case. What is the best way
to factor out these common predicates? Should I simply create an
intermediate fact based upon the common set of conditions and then
reason with that fact, or is there a way of reusing them without
adding another fact to the mix?
Thanks,
Kris
16 years, 4 months
Compiling .drl files inside of a JUnit test
by Ron Kneusel
I'm sure other people have run into this. I'm trying to build a unit test that checks the compilation of an external .drl file. My questions are: How do I get the compiler to locate all the .class files that I reference? When JUnit runs, where does it run from or how can its runtime classpath be manipulated?
Any help appreciated!
Ron
_________________________________________________________________
Keep your kids safer online with Windows Live Family Safety.
http://www.windowslive.com/family_safety/overview.html?ocid=TXT_TAGLM_WL_...
16 years, 4 months
Re: [rules-users] "Not" Non-Existential Quantifier
by ringsah@comcast.net
Ingomar,
I tried this, and indeed that worked. I was surprised, as I thought "not" was meant more to mean that a fact inside its parentheses did not exist, rather than a logical negation, which is the way you used it in your example. However, if I do what you said, it does work exactly how I expected "not" alone to work.
Thanks!
-Hans
-------------- Original message --------------
From: Ingomar Otter <iotter(a)mac.com>
> Hans,
> If you change "not NegativeResult()" to "not (exits
> NegativeResult())" this should result in the expected behaviour.
>
> Cheers,
> Ingomar
>
> Am 31.07.2008 um 17:19 schrieb ringsah(a)comcast.net:
>
> > How is "not" supposed to work with insertLogical? Assume I have two
> > different rules whose conditions are mutually exclusive, like the
> > following:
> > rule "Rule One"
> > when
> > not NegativeResult()
> > then
> > insertLogical(new ApplicantStatus("Approved"));
> > end
> > rule "Rule Two"
> > when
> > NegativeResult()
> > then
> > insertLogical(new ApplicantStatus("Denied"));
> > end
> > Assume that the above two rules are the only way an ApplicantStatus
> > fact can be inserted into working memory. I would expect, after all
> > rules are run, that it would be impossible for there to be one
> > ApplicantStatus with "Approved" as its reason, and another with
> > "Denied" as its reason, in the working memory.
> > I would expect that, before any NegativeResult is inserted, that
> > rule one could run, and insert an ApplicantStatus fact with an
> > "Approved" reason. Then, after a NegativeResult is inserted, that
> > rule two could run, and insert an ApplicantStatus fact with a
> > "Denied" reason. At this point I would expect that the original
> > ApplicantStatus fact, with an "Approved" reason, would be retracted,
> > since the conditions under which it was inserted are no longer true.
> > This is not what I am observing, however. I am finding
> > ApplicantStatus facts with both reasons in working memory at the end
> > of the rules run. Should "not" work as I expect with regard to
> > inserting a fact via insertLogical()? Or is this a known limitation,
> > or simply the way it is designed to work?
> > Thanks,
> > -Hans_______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
16 years, 5 months
"Not" Non-Existential Quantifier
by ringsah@comcast.net
How is "not" supposed to work with insertLogical? Assume I have two different rules whose conditions are mutually exclusive, like the following:
rule "Rule One"
when
not NegativeResult()
then
insertLogical(new ApplicantStatus("Approved"));
end
rule "Rule Two"
when
NegativeResult()
then
insertLogical(new ApplicantStatus("Denied"));
end
Assume that the above two rules are the only way an ApplicantStatus fact can be inserted into working memory. I would expect, after all rules are run, that it would be impossible for there to be one ApplicantStatus with "Approved" as its reason, and another with "Denied" as its reason, in the working memory.
I would expect that, before any NegativeResult is inserted, that rule one could run, and insert an ApplicantStatus fact with an "Approved" reason. Then, after a NegativeResult is inserted, that rule two could run, and insert an ApplicantStatus fact with a "Denied" reason. At this point I would expect that the original ApplicantStatus fact, with an "Approved" reason, would be retracted, since the conditions under which it was inserted are no longer true.
This is not what I am observing, however. I am finding ApplicantStatus facts with both reasons in working memory at the end of the rules run. Should "not" work as I expect with regard to inserting a fact via insertLogical()? Or is this a known limitation, or simply the way it is designed to work?
Thanks,
-Hans
16 years, 5 months
Finding a sequence within the data
by Yoni Mazar
Hi again,
Sorry for nagging, but I'm failing again and again to implement simple
business logic using rules.
Lets assume, we have LabResult facts with date and value fields. The
business requirement is to detect "patients that have at least 3 consecutive
LabResults with value<1 in the last month".
detecting one fact is simple:
LabResult(value<1 && eval(inLastMonth(date)))
But detecting 2 consecutive facts, actually requires that there is not a
third fact in the middle with value >= 1!
something like:
LabResult(value<1, date1:date, eval(inLastMonth(date1))),
LabResult(value<1, date2:date, eval(inLastMonth(date2))),
eval(date1.before(date2)),
not( LabResult(value>=1, date3:date, eval(inLastMonth(date3))),
eval(date1.before(date3))
eval(date3.before(date2)) )
Now, imagine how to detect 3 consecutive facts...
Does someone has a simple idea how to implement this? How comes that one
English sentence is translated to so many lines of code?
Thanks for the help, Yoni
--
View this message in context: http://www.nabble.com/Finding-a-sequence-within-the-data-tp18738051p18738...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months
Re: [rules-users] Finding a sequence within the data
by Greg Barton
Never underestimate the value of data structures.
Give LabResult a pointer to the next (or previous)
LabResult. Then the rule becomes more comprehensible:
$l1 : LabResult( value < 1, eval( inLastMonth(date) )
$l2 : LabResult( value < 1, eval( inLastMonth(date),
next == $l1 )
$l3 : LabResult( value < 1, eval( inLastMonth(date),
next == $l2 )
It's also more easily extensible to longer sequences.
GreG
16 years, 5 months