Performance issue
by Ini
Hi All,
I have written a code to check the properties of a bean using drools based
rules.
I have created the different rules file where different properties of the
bean will be checked.
The code i have written is a as below:
public static void check(Object details,String rule){
long methodStartTime=System.currentTimeMillis();
Resource resource = new ClassPathResource(RULE_CLASSPATH+rule);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
long startTime=System.currentTimeMillis();
kbuilder.add(resource, ResourceType.DRL );
long endTime=System.currentTimeMillis();
System.out.println("Time taken in add resource in milli seconds
is::"+(endTime-startTime));
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
}
StatelessKnowledgeSession ksession =
kbase.newStatelessKnowledgeSession();
ksession.execute(details);
long methodEndTime=System.currentTimeMillis();
System.out.println("Time taken in Method check in milli seconds
is::"+(methodEndTime-methodStartTime));
}
Here in the check method we have three parameters details this is the bean
whose properties need to be checked in rules file, rule this is the name of
rules file which contains all the rules.
Here the issue is that it takes around 4 seconds for the first time and 1
second for all consecutive requests, and 4 second looks too much time for
validating the rules file that has only 10 rules.
Please let me know we have some better way of doing it in drools
--
View this message in context: http://drools.46999.n3.nabble.com/Performance-issue-tp4017688.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 9 months
Guvnor Help !!
by abhinay_agarwal
Hey,
I’ve been using GUVNOR for uploading JARS and creating rules using FACTS..
Now I thing I wanna know is - a rule which is GLOBAL AREA, can it be used
to fire rules which are there in some different package ?? (same facts may
be uploaded in both GLOBAL AREA and the PACKAGE !! .. if requirement asks
for it !!! )
Thanks,
Abhinay
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Help-tp4018290.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 9 months
decision Tables - Operators - starts with/end with??
by gok45
Hi Guys,
Have been using Guvnor to create some decision tables and got a few
questions on the use of certain Operators in the Condition Columns - what
value do you put in for matches and sounds like?
Basically i want to create a condition where i can check starts with or end
with in relation to a string, is this possible using the perdefined
operators or how would i acheive this? so if i want to check "Hello" to see
if it starts with "He" - what value would put in the field?
Using Guvnor 5.2.0
Any help would be appreciated!
Gary
--
View this message in context: http://drools.46999.n3.nabble.com/decision-Tables-Operators-starts-with-e...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 9 months
Possibly Broken drools-core-5.4.0.Final.jar?
by Darin Wilcox
Hello all,
I have an application that was written originally using Drools 5.3.1.Final
that works just fine. I wrote a JUnit test that runs through values
contained in a spreadsheet. Everything was working great. I updated the
application to use Drools 5.4.0.Final and then the test stopped working. I
have debugged the code and here is the exception thrown:
Exception executing consequence for rule "create vcmax" in
org.zoikks.drools: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1283)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at
org.zoikks.drools.xlsx.SampleWorkflowXlsx.check(SampleWorkflowXlsx.java:103)
at
org.zoikks.drools.xlsx.SampleWorkflowXlsx.testSampleXlsxSheets(SampleWorkflowXlsx.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
at ConditionEvaluator0f64b1c63942476d80eb29d1cdffda28.evaluate(Unknown
Source)
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:167)
at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:187)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:181)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ff.defaultConsequence(Rule_create_vcmax_692832fd6e0547e09b6f632175df45ff.java:7)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ffDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ffDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
... 26 more
This appears to be a race-condition occurring someplace within the app
because it executes find some times, yet other times a NPE is thrown. The
location where the exception is originating is new to Drools 5.4.0.Final so
there is nothing to compare against in previous versions. Has anyone else
seen this and/or does anyone know how to solve this problem?
I have attached code that is using Drools 5.4.0.Final. To successfully
re-produce the problem, place a breakpoint at
org.drools.rule.constraint.MvelConstraint.evaluate() [Line 167] and then
step through. The exception has been occurring continuously.
Thanks,
- Darin
13 years, 9 months
ruleflow-group
by al so
looks like one can't activate a ruleflow-group inside a drl file? Only
available via UI?
I was thinking there'll be some kind of setFocus way to control rule
execution using this ruleflow-group.
13 years, 9 months
rule execution flow..
by al so
Given a rule definition file(.drl), Is there any UI tool that can visualize
the execution order of Rules? [based on the controls (salience,etc) defined
inside the rule]
13 years, 9 months
ConcurrentModificationException loading facts from db (Hibernate).
by groovenarula
In my use case, I have ~ 200,000 rows in a table that I need lookup in order
to price an item. Rather than load the entire table into working memory,I'm
trying load the relevant rows (based on a matching criteria) and load those
as facts and then have my rules evaluate the loaded facts. Based on that
I've got the following rule :
rule "Load pricelist"
salience 10000
when
$priceUnit : PriceUnit()
not ( exists Pricelist( id.prodid == $priceUnit.prodid ) )
$unitPrices : ArrayList() from collect ( Pricelist() from
PricelistUtilities.getPriceLists($priceUnit.prodid) )
then
for( Pricelist priceList : (List<Pricelist>) $unitPrices ) {
insert (priceList);
}
end
In the rule above - 'PriceUnit' is the unit that I'm trying to price. And
'Pricelist' is the facts that I'm trying to fetch from a table based on the
prodid matching and inserting those into WM. The
PricelistUtilities.getPriceList returns a list of price list items that
match the 'Product id' (prodid). In the RHS, all I'm trying to iterate over
the list of pricelists and then insert those into WM.
When I execute the rule above, I can see that the rule is executing the
'select' to load pricelists :
Hibernate:
/*
from
PriceList
where
status = 'A'
and end_date >= current_date
and prodid = '010366'
and cover_grade = 'LF' */ select
pricelist0_.prodid as prodid1_,
pricelist0_.cover_grade as cover2_1_,
pricelist0_.cover_series as cover3_1_,
pricelist0_.cover_color as cover4_1_,
pricelist0_.division as division1_,
pricelist0_.location as location1_,
pricelist0_.list as list1_,
pricelist0_.start_date as start8_1_,
pricelist0_.end_date as end9_1_,
pricelist0_.timestamp as timestamp1_,
pricelist0_.status as status1_,
pricelist0_.sold_flag as sold12_1_,
pricelist0_.base_price as base13_1_,
pricelist0_.list_price as list14_1_,
pricelist0_.add_on as add15_1_,
pricelist0_.landed_frt as landed16_1_
from
catalog.pricelist pricelist0_
where
pricelist0_.status='A'
and end_date>=current_date
and prodid='123456'
However, I get an java.util.ConcurrentModificationException when the rule
fires :
org.drools.runtime.rule.ConsequenceException: rule: Load pricelist
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:737)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:701)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at com.generic.rules.utils.DroolsTest.main(DroolsTest.java:46)
Caused by: java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at
com.sample.Rule_Load_pricelist_0.defaultConsequence(Rule_Load_pricelist_0.java:7)
at
com.sample.Rule_Load_pricelist_0DefaultConsequenceInvoker.evaluate(Rule_Load_pricelist_0DefaultConsequenceInvoker.java:27)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 6 more
If I comment the check for existing PriceList Items 'not ( exists Pricelist(
id.prodid == $priceUnit.prodid ) )', then it works fine. But as soon as I
add the check back, it breaks.
Is this a bug or am I doing something wrong ?
Any help / insight will be appreciated.
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/ConcurrentModificationException-loading...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 9 months
eval call from java code
by rogelio_sevilla1
Good day everyone:
Sorry if this is a too basic question.
I'm having a recurrent problem on my rules and I still don't know how to
really solve it, I searched here at the forum but I'm not so sure that the
solutions proposed would work for my use case.
I have to call many different methods on the LHS of some of my rules so I
insert a global 'utils' object and I make my calls within eval() blocks,
like this:
$myObj1: ClassX (eval(globalUtil.reSupplyNeeded(amount) ))
Everything works fine for now. I wrapped all my util methods within try
catch blocks to avoid screwing up my stateful session (in my use case, is
CRITICAL to keep the session alive). So, if an exception is thrown, I return
false or true depending on the method.
My main problem is with evals where I do comparisons like this one:
eval($myObj1.doSomething()==$myObj2.doSomething())
I have many of these and some times I get an annoying NPE. I know I could
add !=null comparisons but my rules would grow considerably. eval is
extremely useful so I was wondering if I can call it from my utility class,
something like this:
On my Drl file:
rule "eval called from here and utility class"
when
$someObj1 : ClassX()
$someObj2 : ClassY()
$myObj : Class1( eval(
globalUtil.doEval($someObj1.doSomething()==$someObj2.doSomething() ) ) )
then
...bla bla bla
end
On my Utility Class
public boolean doEval(ClassIDontKnow argument){
try{
//I don't know if this even exists, just asking if it's possible
return Drools.eval(argument);
}
catch(Exception e){
logger.error("Something bad happened!!");
return false;
}
}
Is something like this even possible?? , if not, other approach that you
would recommend me??
Thanks a lot in advance :-)
--
View this message in context: http://drools.46999.n3.nabble.com/eval-call-from-java-code-tp4018398.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 9 months