Question about getObjects() on workspace with defeasible belief system
by Borris
I am trying the Defeasible belief system (it ties in pretty well with
some of how I want
to structure my project).
After fixing many typos, the rule behaviour seems to be what it should
for a defeasible
rule being correctly defeated (my clash spotter doesn't fire, which it
does if any
part of the defeasible chain is broken). Which is all jolly fun and good
and exciting.
But, my question.
I have a simple workspace dump based upon getting all objects (via
ksession.getObjects() )
and then doing my own tidy presentation. This still shows the defeated
fact as present.
So I know there is still record somewhere of the defeated fact, because
if the workspace
changed such that my defeater was retracted, then it needs to make the
fact visible again.
But I wasn't expecting to see it via getObjects(). Is that the intended
behaviour? If so,
is there a way to enquire whether a fact is in the "defeated state" or
not that I could
add to my tidy workspace dumper?
Thanks!
Borris
11 years, 8 months
Problem when I cleaning the production memory.
by braveheart85
Hello guys,
I have a very strange behaviour when i execute this fragment of code:
private void _clearKnowledge() {
try {
Collection<KnowledgePackage> knowledgePackages =
_knowledgeBase.getKnowledgePackages();
for (KnowledgePackage singlePackage : knowledgePackages) {
_log.debug("Removing knowledge in drools engine");
_log.debug("package name: " + singlePackage.getName());
_knowledgeBase.removeKnowledgePackage(singlePackage.getName());
}
} catch (NullPointerException e) {
// TODO An error about a missing package rarely occurs.
_log.warn("Drools Engine has tried to remove a missing knowledge
package.");
}
}
Sporadically the system raise this ugly exception:
Caused by: java.lang.NullPointerException
at
org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:252)
at
org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:459)
at
org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:1099)
at
org.drools.common.AbstractRuleBase.removePackage(AbstractRuleBase.java:1017)
at
org.drools.impl.KnowledgeBaseImpl.removeKnowledgePackage(KnowledgeBaseImpl.java:202)
at
org.titan.frontend.memory.drools.DroolsEngine._clearKnowledge(DroolsEngine.java:304)
I thought about timing issues, but each group of interaction with the engine
is protected with a synchronized method on the facade of the module. The
try-catch is the unique solution that I have found so far.
Thanks
Andrea
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-when-I-cleaning-the-production-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
Activation-group doubt
by bjs
As far as i understand the activation group fires only one rules for a given
group.
But does it run once for each fact inserted or only just once.
for example i have activation group act1 with 3 rules: rule1,rule2,rule3 and
inserted 4 facts .
But the rule1 runs only once , i wanted rule1 to run for each of the 4 facts
inserted.
--
View this message in context: http://drools.46999.n3.nabble.com/Activation-group-doubt-tp4030388.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
condition altered while unmarshalling a drl to guided rule
by Sumit Dhaniya
I created a guided rule and when I open it again some conditions which I
wrote using the --Text-- option from drop down are altered.
It seems the issue is only with unmarshalling because condition remains
unaltered in rdrl file until you save it again so everything is fine if you
change it every time you make any change to the rule or save it.
Below is the scenario to reproduce(use 6.1CR2) :-
1) Made a Maven-ized JAR containing the following classes:
package com.demo;
import java.util.List;
public class Foo {
private List myList;
public List getMyList() {
return myList;
}
public void setMyList( List myList ) {
this.myList = myList;
}
}
public class Bar {
private String myString;
public String getMyString() {
return myString;
}
public void setMyString( String myString ) {
this.myString = myString;
}
}
2) Uploaded JAR to the workbench's Artifact Repository
3) Added a project dependency on this artifact
4) Added an Import Suggestion for java.util.List
5) Created a new Guided Rule
6) Imported Foo,Bar and java.util.List (Config tab)
7) Created the following rule:
package org.mortgages;
import java.lang.Number;
import java.util.List;
import org.anstis.MyListClass;
rule "r1"
dialect "mvel"
when
$foo : Foo()
Bar : Bar( myString == $foo.myList.get(1))
then
end
8) Validate rule :- will be vaidated
9) Save and close rule
Now when rule will be opened again this get(1) will change to get moreover
while creating rule get(index) method is not specified in dropdown so
selected -- Text -- option to create the rule.
DRL remains in valid format until overwritten in another save.
--
View this message in context: http://drools.46999.n3.nabble.com/condition-altered-while-unmarshalling-a...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
EventFactHandle retained in memory after FactCount reaches 0 for temporal-based rule
by Kent Anderson
The following rule produces a memory leak in Drools 6.1.0-SNAPSHOT:
(Stream mode)
declare MyEvent
@role(event)
@timestamp(timestamp)
end
/* If a RAISE is buffered for N seconds, send it out */
rule "forward raise"
no-loop
duration (3s)
when
$raise : MyEvent(eventState == EventState.RAISE, $raiseId : eventId)
then
System.out.println("Forwarding RAISE(" + $raiseId + ")");
delete($raise);
end
I see the rule fire as expected, printing out the message 3 seconds after the event is added into the session. While the event is waiting, I see a FactCount of 1 in the session. After the rule fires, the fact count goes to 0. However, using JVisualVm, querying the heap dump shows 1 instance of MyEvent, referenced by an EventFactHandle and several other Drools objects.
Is this a bug, or is there a better way to write this rule so Drools’ internals let go of the object after it is no longer a fact?
11 years, 8 months
Split in rule flow in drools
by bjs
Hello everyone,
I have doubt about the use of split in the rule-flow.
I created a split with constraint1 and constraint2.
But even if condition in constraint2 is fulfilled by a fact it fires the
rules under constraint1 branch if the rules fulfill the when clause under
constraint1 branch.
This should not be the case cause the split should mean the rules in the
branch under constraint2 should be fired.
--
View this message in context: http://drools.46999.n3.nabble.com/Split-in-rule-flow-in-drools-tp4030378....
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
Caching in Drools 5.5.0
by Rajeswari
We are using Drools 5.5.0 and have created Models and Rules via the
Workbench.
>From our application code, we create model classes and the models are then
modified depending on the rules configured and the modified objects are used
further in our code.
Example:
RuleModel - is a model containing fieldName and resultList.
Several rules are written to return an appropriate resultList depending on
the value of the fieldName.
We would like to implement Caching here. At several points within our
application, we create these RuleModel with sometimes the values of the
fieldName being the same - How can we cache the RuleModel (after it gets
modified by applying the rules for the first time)
Eg: RuleModel with value of fieldName as F1
RuleModel with value of fieldName as F2
all needs to be in cache. Anytime the application needs the object with F1
for the next time, we would use that insteading of having to apply the rules
again.
We will further put it in a feature to refresh this cache at regular
intervals.
--
View this message in context: http://drools.46999.n3.nabble.com/Caching-in-Drools-5-5-0-tp4030374.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months