Drools HA
by gboro54
Hi everyone. We are currently evaluating drools as a potential solution of a
high throughput billing system. As is such we are planning to have messages
read from a queue from 2 or more nodes. One thing we are trying to figure
out is best way to share state in drools. The situation we are facing is as
follow:
-Node 1 reads message 1
-Node 2 reads message 2
-Node1 begins execution of rules on message 1 with context information
-Node2 begins execution of rules on message 2 with context information
-Node 1 updates the context information such that rules being executed by
node2 should be reevaluated(i.e node 1 in the rules session executed an
update on the context object)
What is the best way to handle this situation?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-HA-tp3619496p3619496.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
KnowledgeAgent and applyChangeSet
by bob.breitling
If I have a KnowledgeAgent and I create a URL Resource and set its
basicAuthenication, username and password attributes then I call the agents
applyChangeSet method I get a HTTPD 401 response from the Guvnor. It does
not happen to my resourse which has a valid username and password, but it
happens to the resource in the changeSet xml tag.
It would seem to me that the resources that are built from the resource I
passed would inherit the basicAuthenication, username and password
attributes that I set and know work, but they don't and I get this error.
If I debug the code and filling in those values on the resource passed to
the createPackageFromResource method before the resource stream is read the
code works.
I am using the NilAuthenicator in the Guvnor components.xml and that seems
to be working. I get access to the Guvnor without being asked for
credentials.
I tried to configure my jboss (4.2.0) in login-config.xml to allow access to
everything as guest. But no luck.
Any suggestions?
Bob
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/KnowledgeAgent-and-ap...
Sent from the Drools - User mailing list archive at Nabble.com.
12 years, 12 months
Two bugs(?) of drools 5.3
by Miles Wen
Hi all,
I'm using drools 5.3.0.Final.And I think I found two possibly bugs:
1): drl compilation failed when encountering multiple continuous '!' (a.k.a
'not' operator)s.for example:
rule "out"
when
Msg(!!!false)
then
end
the code above won't compile, but 'Msg(!false)' compiles correctly. I
remember there's no such problems when using drools 5.0, this caused some
incompatibility issues in our system...
2): Weird exception thrown: java.lang.ClassCastException:
org.drools.reteoo.InitialFactImpl cannot be cast to XXX..., for example:
rule "test"
when
l1:Msg(str == 'test') and
l2:Msg(!bool) or
eval(!false)
then
end
this code above throws exception at runtime:
org.drools.RuntimeDroolsException: Unexpected exception executing action
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction@743fbbfc
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:977)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:315)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
at com.sample.DroolsTest.main(DroolsTest.java:56)
Caused by: org.drools.RuntimeDroolsException:
com.sample.Rule_testEval0Invoker@3e1b05a2 : java.lang.ClassCastException:
org.drools.reteoo.InitialFactImpl cannot be cast to com.sample.Msg
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:119)
at
org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:178)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:197)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:146)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:158)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at org.drools.reteoo.Rete.assertObject(Rete.java:107)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:284)
at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:404)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:975)
... 6 more
Caused by: java.lang.ClassCastException: org.drools.reteoo.InitialFactImpl
cannot be cast to com.sample.Msg
at com.sample.Rule_testEval0Invoker.evaluate(Unknown Source)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114)
... 17 more
Is there any workaround for those problems? especially the 2nd one...
Any help would be appreciated,
Thanks!
--
Regards.
Miles. Wen
12 years, 12 months
Working Memory and agenda-group
by Mike Key
I am a fairly new Drools user and am trying to understand how working
memory is segmented when using agenda groups. I have an agenda-group that
has focus set immediately from the session as follows with a few objects
being inserted:
ksession.insert(objectA);
ksession.insert(objectB);
ksession.getAgenda().getAgendaGroup("Foo").setFocus();
I have 2 rules simplified down to illustrate my confusion. The first rule
simply sets some default values evaluated in the second rule if objectA
exists. In the example that works I set the defaults in the RHS
explicitly. However I want to use these defaults from different
agenda-groups, so when I put them in a function, the second rule never
fires, the activation is created for the first rule but never the second.
Can someone tell me why the use of a function seems to alter the truth of
the rule?
THIS WORKS:
declare SomeDefault
minValueA : Integer
minValueB : Double
maxValueB : Double
end
rule "Check Object A and Set Default"
agenda-group "Foo"
salience 100
when
$a : ObjectA()
then
default = new SomeDefault()
default.minValueA = 100
default.minValueB = 20.0
default.maxValueB = 20000.0
insert(default)
end
rule "Use the defaults"
agenda-group "Foo"
salience 100
when
$default : SomeDefault()
then
System.out.println("Default minA=" + $default.minValueA)
end
THIS DOES NOT WORK:
declare SomeDefault
minValueA : Integer
minValueB : Double
maxValueB : Double
end
rule "Check Object A and Set Default"
agenda-group "Foo"
salience 100
when
$a : ObjectA()
then
insertDefault(drools.getWorkingMemory())
end
rule "Use the defaults"
agenda-group "Foo"
salience 90
when
$default : SomeDefault()
then
System.out.println("Default minA=" + $default.minValueA)
end
function void insertDefault(WorkingMemory workingMemory) {
SomeDefault default = new SomeDefault();
default.setMinValueA(100);
default.setMinValueB(20.0);
default.setMaxValueB(20000.0);
workingMemory.insert(default);
}
In the latter (non-working) example the first rule activates and then
drools returns, it never even attempts to try to fire the second rule.
However in the working example BOTH rules fire as I would expect. I am
guessing this is a simple misunderstanding on my part. Any assistance in
understanding why this nuance doesn't seem to work would be greatly
appreciated.
Thanks.
MiKey
12 years, 12 months
Null pointers and field level validation
by Ronald Albury
I have been experimenting with using the same set of rules for both record
validation (when a completed record come to us from a 3rd party) and field
validation (when the record is filled out via a web app). I don't want to
have two separate sets of rule validation (twice the maintenance, twice the
confusion). I have no problems with the record validation, but some issues
with field validation that I would like to get input on.
First - the idea for the field validation is to use Ajax to send the field
contents to the server when the field looses focus, so that we can provide
rapid feedback to the user if they have entered a field incorrectly. Most
of the intra-field validation will take place at the end of the user input,
when the form is submitted.
The fact that Drools has lots of null protection was very helpful ... I
could partially fill in a sub-record with the field input, submit it to the
rules engine, and only those rules accessing a filled-in (non-null) field
would be evaluated. I am interested in feedback on this concept.
The general issue I'm having with my experiment is that not all
null-security is created equal.
1) if I have a Boolean field then Drools throws an exception if the rule
is based on that field and the field is null. I found a work around by
testing if the field is equal to true.
2) if I have a String field then Drools throws an exception if that
field is tested with 'matches'. The only work around I've come up with is
to use a null-protected utility method instead of the built-in 'matches'.
3) if I have a String field then Drools throws an exception if that
field is tested with 'in'. Here again, the only work around I've come up
with is a utility method.
Is my concept flawed from the start? Any suggestions on addressing the
issues mentioned above? Any suggestions on issues I have yet to encounter?
Thanks
Ron
12 years, 12 months
Access metadata of declared drools expert types in Java
by Tobias Neef
Hi,
First I have to say. Drools is a very nice tool with great
documentation. Thats the first time I have to use the ML because I
write a little framework which makes some obscure use of Drools expert
;).
But now my problem: I have a type which I declared like:
declare MyMarker
@Marker
feature : String @Feature
end
When I put an instance of that type into the KB I want to grab those
entries with a given @Marker / annotation. So I tried doing that with
reflection on the MyMarker class which did not work. Also when I try
to get a FactType instance I do not find a way to access those
metadata information. For the class annotation @Marker I see that the
FactType instance contains a private field annotation which includes
the correct type. But I see no way to access this information. The
feature field itself can be accessed but no annotation information is
available:
{feature=FieldDefinition{name='feature', type='java.lang.String',
key=false, inherited=false, index=1, initExpr='null',
annotations=null, accessor=[ClassFieldExtractor class=package.MyMarker
field=feature]}
A second minor problem is the way I access the fact type. Is there a
better way to do this?
for (Object object : result) {
Class c = object.getClass();
Package p = c.getPackage();
String packagename = p.getName();
String classname = c.getSimpleName();
FactType ft = knowledgeBase.getFactType(packagename, classname);
if (ft!=null) {
//stuff
}}}
Best Regards,
Tobias Neef
12 years, 12 months
Rule evaluation logic
by MarcoMojana
I have reduced my problem to a minimal example:
- I use a pseudo clock and stream mode processing
- The events are inserted using a succession of advanceTime(), insert(),
fireAllRules()
- I have three events named: Thief, SwitchOn and SwitchOff
- I have three rules similar to:
rule "detect theft"
when
$t : Thief() from entry-point "thieves" // Line A
$lastSwitchOn : SwitchOn(this before $t) from entry-point "lightsControl"
// Line B
SwitchOff(this before $t, this after $lastSwitchOn) from entry-point
"lightsControl" // Line C
not( SwitchOff(this before $t, this after $lastSwitchOn) from entry-point
"lightsControl" ) // Line D
then
System.out.println($t);
end
The first rule is composed of lines A, B, the second of lines A, B and
C and the third of lines A, B and D. Please note that line D is the negation
of line C.
- Inserting the same sequence of events, only the first rule triggers.
This seems strange to me, because:
1) if the first rule triggers, then "Line A" and "Line B" = true
2) if the second rule doesn't, then "Line A" and "Line B" and "Line C" =
false.
3) from 1) and 2), it follows "Line C" = false
4) from 1) and 3), it follows that "Line A" and "Line B" and not "Line C"
= true, so the third rule should be triggered, but it is not. Why?
--
MM
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-evaluation-logic-tp3620772p3620772...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 12 months
DSL/DSLR question
by Rob Fisher
I have a question given the following code:
Inserted fact setter method:
public void setqrpQualRule6(String qrpQualRule6) {
qrpQualRule6 = qrpQualRule6;
}
DSL
[consequence][]Write {AttributeName} on {objectVarName} as
{customCode}=modify ({objectVarName}) \{{AttributeName}={customCode} \};
DSLR
rule "test rule 1"
dialect "mvel"
when
ThereIsQrpRuleFlagData called QrpFlags
- where $var04 is QrpQualFlagRule6 and is equal to "N"
then
Write QrpQualFlagRule6 on QrpFlags as "Y"
DRL Translation
modify (QrpFlags) {qrpQualRule6="Y" };
Question....Does Drools create the "get" behind the scenes? I'm guessing
yes, because the rule is firing and the qrpQualRule6 attribute is getting
set to "Y".
--
View this message in context: http://drools.46999.n3.nabble.com/DSL-DSLR-question-tp3619216p3619216.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 12 months
Usage of completeMoveTabuSize
by Patrik Dufresne
Hi,
I've try to use the completeMoveTabuSize for my problem and I come to
realize it's not working properly. To make sure, I've check it's usage in
the smart Travelling Tournament. It's look like, the hashCode function it
not well implement.
Here my comprehension of the completeMoveTabuSize functionnality :
When completeMoveTabuSize sets to 7, the last 7 moves are consider Tabu. So
the accept chance of the last 7 moves should be 0.0.
To check the tabu, the acceptor use a HashMap and so the hashCode of the
last 7 moves are used to speed up the comparison. In the smart travelling
tournament, the implementation of hashCode is wrong since it's include the
hashCode of the planning-entity which change over time.
May someone confirm this ??
To figure it out, I add a breakpoint in the equals function of the Move
object (and it's never called).
--
Patrik Dufresne
12 years, 12 months