Cutom Attributes in Drools
by dme1
Hi,
Is there support for Custom Attributes in Drools? What I want to do is add
attributes which determines when rules should be fired as well as attributes
that the rule updates which I can query at a later time.
E.g. Fire rule only for specific regions. So when new rules are
created/added BAs can define if it is applicable to specific regions.
Then the rule could result in a violation that could or could not be
overriden, so I want to add an attribute called override which is set by the
rule, which I can check after all rules are fired. I can use MetaData to
define this, but I need a pre-defined list which BAs can choose from when
creating a new rule.
Any thoughts on how I can implement this would be appreciated.
Thanks,
dme
--
View this message in context: http://drools.46999.n3.nabble.com/Cutom-Attributes-in-Drools-tp4019692.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Re: [rules-users] Data Model Dependencies in Guvnor
by Stephen Masters
I think this is the only option:
Upload the model into the global area, then within each package, you can create a new model and instead of uploading you can "Import from Global".
Although this is duplication rather than dependency, and you need to copy into each of your packages every time the model is updated. :-/
There is a Jira based on a similar request, but it has been unresolved for a good while:
https://issues.jboss.org/browse/GUVNOR-1401
Steve
> On 14 Sep 2012, at 14:54, dme1 <mehtad(a)hotmail.com> wrote:
>
>> Thanks Stephen for the detailed explanation. I agree that its not a good
>> option to add the dependency to the Server lib, and I also do not want to
>> mix up facts between my Java project and Drools, for various reasons.
>>
>> One other related question though, is there a way in Guvnor to specify
>> dependency amongst packages, i.e. can I say that the Extended Package
>> depends on the Common Package and it able to view the Model and all other
>> artifacts from Common. I did not see a way to do this, but want to check if
>> there is any way this can be achieved, which can help with a number of
>> things including Overrides etc. (when implemented)
>>
>> Thanks,
>> dme
>>
>>
>>
>> --
>> View this message in context: http://drools.46999.n3.nabble.com/Data-Model-Dependencies-in-Guvnor-tp401...
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
13 years, 6 months
Data Model Dependencies in Guvnor
by dme1
Hi,
I have created 2 projects in Eclipse - the first one is the Base Project
with the Model defined for this as BaseModel.jar. The send one is the
Extension Project which inherits the BaseModel and extends it, this Model is
called ExtendedModel.jar.
In Eclipse I can set the dependency on BaseModel in the Extended Project and
can write rules using the Base and Extended Models.
Now I create 2 packages in Guvnor one to represent the Base Project, the
second to represent the Extended Project. I upload the BaseModel to the
BaseProject and the associated technical rules and this all works well.
In the Extended Package I upload the "BaseModel.jar" successfully, however
when I try to upload the "ExtendedModel.jar" it gives me an Error. The only
way I can resolve my error is to update the ExtendedModel.jar to include all
classes from BaseModel.jar, so it seems like the Guvnor requires all
dependencies to be resolved within the Model jar and cannot reference other
Data Models within the same package.
Is there a way for Guvnor to lookup the other Models for dependencies and
resolve the dependencies? If not what is the recommended approach for
specifying dependent models in Guvnor?
Thanks,
dme
--
View this message in context: http://drools.46999.n3.nabble.com/Data-Model-Dependencies-in-Guvnor-tp401...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
problem with pesisted stateful knowledge session and Length Sliding Window
by henrychen
Hi all,
I am facing a problem with persisted stateful knowledge
session, please help me. My rule is listed as below:
package com.sample
import com.sample.Event;
import java.util.List;
declare Event
@role(event)
end
rule "test"
when
$list : List() from collect(Event() over window:
length(2))
then
System.out.println("----print out in rule, size of
the list collected from window is:" + $list.size());
end
The problem is,
when use a normal stateful session(created by the calling
kbase.newStatefulKnowledgeSession()), *when a third fact inserted, the
session working memory only retains list of 2, as expected.*
when use a persisted stateful session(created by the calling
JPAKnowledgeService.newStatefulKnowledgeSession()), insert 2 facts first.
Then restore this session by
JPAKnowledgeService.loadStatefulKnowledgeSession(), and *insert a third
fact, the session working memory grows to list of 3?*
By the way, I am using version 5.2.0.Final. And after I upgrade
to version 5.4.0.Final, the test result of persisted session becomes to
normal.*The attachment is my test program and you can repeat it.*
I want to ask you if there is something missing that I need to
do in 5.2.0.Final?
Thank you in advance, any help will be appreciated.
http://drools.46999.n3.nabble.com/file/n4019766/drools-session-persis-dem...
drools-session-persis-demo.zip
--
View this message in context: http://drools.46999.n3.nabble.com/problem-with-pesisted-stateful-knowledg...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
exception jitting problem
by brendanneff
Hello,
I recently "inherited" drools management of our system when the previous
code owner left the company unexpectedly, and sure enough, as soon as he
left, I found the errors posted below. Being new to drools, I'm pretty lost
about how to begin troubleshooting this issue.
I read a few forum posts about updating to 5.4 CR1 (we're using 5.4 Final),
but wanted to ask and see if that's really the cause before I start changing
the version. I also saw that casting as an Integer, which we do, could
solve the problem. Could someone take a look at this and let me know if
changing to CR1 would fix the issue or if there's a simpler solution?
A little more info:
We recently started increasing our traffic, which may be why we didn't see
this issue before.
I can't tell if this happens every 21st call or not, as was noted in other
forum posts. We have multiple rules in each .drl file, and it seems like
only these two rules are referenced, and none of the others. All rules in
the file are called, so shouldn't the others cause the exceptions too?
As far as I can tell, we're passing valid values each time to the rules.
If there's any other information I can provide, please let me know.
Thanks
Exception in thread "Thread-69" java.lang.RuntimeException: Exception
jitting: !getActiveLender($loan.getCurrentLender().getName()).canMakeLoan
at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:219)
at
org.drools.rule.constraint.MvelConstraint.access$000(MvelConstraint.java:41)
at
org.drools.rule.constraint.MvelConstraint$1.run(MvelConstraint.java:201)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.VerifyError: (class:
ConditionEvaluator30c1aafd8a5c4402813396a1ab9f4739, method: evaluate
signature:
(Ljava/lang/Object;Lorg/drools/common/InternalWorkingMemory;Lorg/drools/reteoo/LeftTuple;)Z)
Expecting to find integer on stack
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.getConstructor(Class.java:1674)
at
org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:173)
at
org.drools.rule.constraint.ASMConditionEvaluatorJitter.jitEvaluator(ASMConditionEvaluatorJitter.java:53)
at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:217)
... 5 more
Exception in thread "Thread-70" java.lang.RuntimeException: Exception
jitting: new Integer(getCustomer().getLatestEmployer().monthlySalary) < 1251
at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:219)
at
org.drools.rule.constraint.MvelConstraint.access$000(MvelConstraint.java:41)
at
org.drools.rule.constraint.MvelConstraint$1.run(MvelConstraint.java:201)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.VerifyError: (class:
ConditionEvaluatorcc9abc72a67b4dd2bbde979a1a2baa48, method: evaluate
signature:
(Ljava/lang/Object;Lorg/drools/common/InternalWorkingMemory;Lorg/drools/reteoo/LeftTuple;)Z)
Expecting to find integer on stack
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.getConstructor(Class.java:1674)
at
org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:173)
at
org.drools.rule.constraint.ASMConditionEvaluatorJitter.jitEvaluator(ASMConditionEvaluatorJitter.java:53)
at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:217)
... 5 more
Here are the rules that seem to be causing the errors:
rule "Cashcure - Average Monthly Income Less Than 1251"
when
$loan : CMVNewLoanBean( new
Integer(getCustomer().getLatestEmployer().monthlySalary) < 1251)
then
$loan.setLenderError($loan.getCurrentLender().getName(), 20253);
end
rule "Cashcure - Loan Cap Has Been Reached"
when
$loan : CMVNewLoanBean(
!getActiveLender($loan.getCurrentLender().getName()).canMakeLoan )
then
$loan.setLenderError($loan.getCurrentLender().getName(), 20259);
end
--
View this message in context: http://drools.46999.n3.nabble.com/exception-jitting-problem-tp4019764.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Drools - Search and Reporting
by dme1
Hi,
Is there any way to search and/or generate reports from the Rule Repository
based on different criteria like Facts, Field Values, Attributes, MetaData
etc.
E.g. If I have a rule
rule "Test"
when
@SomeMetaData("value1")
ruleflow-group "abcd"
p : Person (age > 25, country = "XYZ")
then
p.setSomeField("value");
I would like to search for all rules in the ruleflow-group abcd, and
MetaData=SomeMetaData;
or for rules which are defined for Person with age as a criteria; or for
Person with age > 25 etc.
I would like to do this in Guvnor and Eclipse if possible.
If the features do not exist what would be the best way to write a custom
search feature to satisfy this requirement.
Thanks,
dme.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Search-and-Reporting-tp4019747.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Package footprint
by JP Chemali
Hi all,
I'm trying to reduce the memory footprint of packages in my application (for
performance reasons they are dynamically loaded from disk), and I was
wondering if some of you had any experience with the subject?
So far the optimizations that I can come up with in 5.4.0.Final version are
all about reducing the sizes of generated classes:
- Package name in the drl file should be as small as possible, one letter is
best (even better that no package at all)
- Rule name should be as small as possible as it is used to generate the
consequence class name
- Write as less code as possible in the consequence
- Use as few as possible eval statements
- By using my own JavaDialectConfiguration and MVELDialectConfiguration when
building the knowledge, I can remove the random number on class names that
was added in the recent versions (don't understand why it was added in the
first place? Does anyone know?)
I see some leeway to shorten the names of the following generated classes
but the amount of overriding to change the "default" consequence name and
the suffixes is a bit too exotic for me:
- <PackageName>.<RuleName>DefaultConsequenceInvoker
- <PackageName>.<RuleName>DefaultConsequenceInvokerGenerated
Any advice, other leads some of you might have?
Thanks in advance
--
View this message in context: http://drools.46999.n3.nabble.com/Package-footprint-tp4019721.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months