StatefulKnowledgeSession, serialization and FactHandle question
by Laird Nelson
Hello; I'm using Drools 5.2.0-SNAPSHOT.
I have a StatefulKnowledgeSession spawned from a KnowledgeBase whose
KnowledgeBaseConfiguration is set up to use equality, not identity for (as I
understand it) testing to see whether a fact is in the base or not.
I have this verified with a (nasty) assert statement (I didn't see any other
way to get the KnowledgeBaseConfiguration out, which looks like an API
omission to me):
assert ((InternalRuleBase)((
KnowledgeBaseImpl)sks.getKnowledgeBase()).getRuleBase()).getConfiguration().getAssertBehaviour().equals(AssertBehaviour.EQUALITY);
OK, so the internal knowledge base is using equality.
I stick some facts in via insert. Then I serialize the session using all
the right classes from org.drools.marshalling. I choose the full
serialization mode.
As I understand it, this means that the knowledge base and the facts will
all be serialized. I am aware of the fact that all facts will get new
identities.
At some point in the future, I deserialize the session (successfully).
When I take the same object that I inserted, and call
statefulSession.getFactHandle(myObject), I get null back.
This is despite the fact that my object has an equals() method, and that the
equals() method is heavily unit tested (and simple).
That is, despite the fact that the KnowledgeBase is confirmed to use
equality, not identity, there does not seem to be a way to test if the
session contains a particular fact. It's like identity is still being used.
Am I overlooking something obvious?
Thanks,
Laird
14 years, 11 months
Ask for help on rule authoring
by Benson Fung
Hi,
I got the following rule problem.
The rule is like :
1. | rule "Rule1"
2. | dialect "mvel"
3. | when
4. | ad : ApplicationData( age == "null" , age.size() == 0)
5. | then
6. | ad.setReturnMsg( "age should not be null or empty" );
7. | end
where setReturnMsg is a method of ApplicationData Fact();
However, I got the validation error :
[Rule1] [ERR 101] Line 4:49 no viable alternative at input ')' in rule
"Rule1" in pattern ApplicationData
[Rule1] [ERR 102] Line 4:51 mismatched input '==' expecting ')' in
rule "Rule1" in pattern ApplicationData
Please help what the problem is.
Thanks
14 years, 11 months
Drools Dyanmic Class creation Problem
by saurabh maheshwari
Hi sir ,
I am facing one issue regarding dyamic class cretion and inserting it's
object into drools memory.
i have created a dyanmic class test and loads it like that
MyClassLoader clr =new
MyClassLoader(Obj.getClass().getClassLoader());
Obj.clazz= clr.loadClass("test");
//Drools Configuration
KnowledgeBuilderConfiguration kbc =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null,clazz.getClassLoader());
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(kbc);
String path = System.getProperty("user.dir");
StringBuilder drlFile = new StringBuilder(path);
drlFile.append(System.getProperty("file.separator")).append("myRule.drl");
kbuilder.add(ResourceFactory.newFileResource(drlFile.toString()),
ResourceType.DRL);
if (kbuilder.hasErrors())
{
System.out.println(kbuilder.getErrors());
return;
}
KnowledgeBaseConfiguration kbaseConfig
=KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null,
clazz.getClassLoader());
kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
ksession = kbase.newStatefulKnowledgeSession();
Now my drl file is like that
package dyanmicclass;
dialect "java"
rule mytest1
when
$tx : test($pp : name )
then
globalArrayList.add($tx);
System.out.println($tx );
end
this is giving me a error
KnowledgeBuilder created.
Unable to generate rule invoker. : [Rule name='mytest1']
dyanmicclass/Rule_mytest1_0DefaultConsequenceInvoker.java (22:886) :
test cannot be resolved to a type
dyanmicclass/Rule_mytest1_0DefaultConsequenceInvoker.java (22:898) :
test cannot be resolved to a type
Rule Compilation error : [Rule name='mytest1']
dyanmicclass/Rule_mytest1_0.java (6:214) : txn cannot be resolved to
a type
but while i am doing like that
dialect "java"
rule mytest1
when
$tx : test($pp : name )
then
System.out.println($pp );
end
it gives no error .
I am not able to find the cause of the problem .
am i wrong in any configuaration.
Thanks
Saurabh
14 years, 11 months
accumulate min over java.util.Date
by jkrupka
Should I be able to do an accumulate min over java.util.Date objects? Like
this:
$minDate : Date() from accumulate(MyFact ($startDate : startDate),
min($startDate))
I would have thought so, but when I try it, I'm getting:
Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to
java.lang.Number
at
org.drools.base.accumulators.MinAccumulateFunction.accumulate(MinAccumulateFunction.java:76)
If it should work, then it's possible I'm doing something else wrong, but
everything looks correct to me. I can always work around it by getting the
milliseconds from the Date object and doing the min over that... it's just
not as clean looking.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/accumulate-min-over-j...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months
[Drools Interest] Dynamic rule loading from DB
by bilasini sahoo
Hi All,
I am new to this Drool rule ingine use.
Normal drl is working for me.
But mu requirement is i need to configure all the rules in Data base and
from there i need to inject to the Rule engine.This is beacuse Rules can be
configured any point of time.
Please let me know if is there any special foemat of rule configuration is
required so that creating rule file would be easier
currently i have configured as
(Company=CCC && Organisation=OOO and Dept=HR) OR (Country=UK)
(Company=CCC && Organisation=OOO )and (Dept=HR OR Country=UK)
please advice. I am stuck with this proble since 2days
Thanks,
Bilasini
14 years, 11 months
Attempted JIRA on BPMN2 issue in Eclipse
by drdaveg
I tried to submit this to https://issues.jboss.org/secure/, but my password
reset, while successful doesn't let me in to submit a JIRA.
On the stable (M1?) version of 5.2 I encounter the following exception.
- Create a BPMN2 diagram with a nest subprocess that has a rule task with
ruleflow-group specified (or not)
- Save it
- Reopen it
Dialog box in Eclipse:
Could not read RuleFlow file
An exception occurred while reading in the RuleFlow XML: the prefix "G" for
attribute "g:ruleFlowGroup" associated with the element type
"businessRuleTask" is not bound. See the error log for more details.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Attempted-JIRA-on-BPM...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months
execute Rules selectively
by Benson Fung
Hi,
I have setup about 10 rules in the rulebase. Can you tell me how I
can execute more than one specific rule at the same time? Please help
Thanks
Benson
14 years, 11 months
This Tuesday!!! - Red Hat & Accenture: BRMS & BPMS Event (London)
by Mark Proctor
http://blog.athico.com/2011/02/red-hat-accenture-brms-bpms-event.html
Reminder that this Tuesday 24th of March you can come and hear all about
Drools and jBPM5!!!!
Registration Page:
https://engage.redhat.com/forms/UK_Event_Accenture290311
Join Red Hat and Accenture on Tuesday 29th March at Accenture Old Bailey
to understand how Business Rules Management Systems (BRMS) and Business
Process Management Systems (BPMS) can help businesses leverage
technology more effectively and increase productivity. See how
Enterprise Open Source is leading the way with powerful capabilities and
industry-leading innovation.
There will be 2.5 hours of technical talks, starting at 9am. Full
timings and agenda here:
http://www.europe.redhat.com/events/rh-accenture-seminar/
Speakers:
Mark Proctor - Drools Co-Founder and Poject Lead
Kris Verlaenen - jBPM Lead
Michael Anstis
Geoffrey de Smet
Talks (from core developers, there are other talks too:
Introduction to Rule Based Systems (Mark Proctor)
Introduces Drools and explains what a rule based system is and how it
works. We will also cover event processing on a rule based system.
Why BPMN2 Matters (Kris Verlaenen)
jBPM5 has just been released as premier Open Source BPMN2
implementation. Come and hear how this changes your whole legacy
approach to BPM.
Using Guvnor for Enterprise Systems (Geoffrey de Smet)
Guvnor provides a web interface to your knowlege systems, such as rules
and bpm. This talk provides a gentle introduction into Guvnor and how to
use it.
Decision Tables in Depth (Michael Anstis)
Decision Tables is now a major focus for us, we want to show you why
we'll have the slicket decision table environment out there.
14 years, 12 months
endless loop even with "no-loop"
by James Gu
Hi, I am working on rule and found that it is very easy to cause endless
loop.
For example:
Rule 1 match status and update message.
Rule 2 match type and update message.
This will cause endless loop even I add "no-loop" on each rule. Is there
anyway to avoid this? for example: each rule only execute one time, or set a
maximum execute times.
rule "rule 1"
no-loop
when
m : Message( status == Message.HELLO)
then
System.out.println( "rule 1" );
m.setMessage( "update 1" );
update( m );
end
rule "rule 2"
no-loop
when
m:Message( type=="type1" )
then
System.out.println( "rule 2" );
m.setMessage( "update 2" );
update( m );
end
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/endless-loop-even-wit...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 12 months