Drools Design Patterns
by Ross H
I've been using Drools for about a year now, but still consider myself a
newbie,
although I'm starting to get a better idea of how to implement solutions,
for the
experts this is probably second nature.
Whilst the Drools doco is very good, and the blog/mailing lists are a great
source of info,
and there are now some very good books on Drools, there is a hugh amount of
functionality emerging in the Drools project, it's almost becoming a full
time activity just
to keep up. I wonder if the time is coming to start collecting real
experiences into a form that
makes it easier for new users to work out how to attack their problem.
I hate to re-invent the wheel and if this exists in some form elsewhere, I'd
like to know.
If not, then it might be good to capture this knowledge in some way. I'm
interested in
some views from the user community on what they would like to see.
Maybe the way to go is add some pages to the JBoss Drools wiki and evolve it
from there,
and provide a way for the drools user community to contribute to the overall
success of Drools,
rather than just ask questions.
16 years, 3 months
(no subject)
by Post Office
Dear user rules-users(a)lists.jboss.org, administration of lists.jboss.org would like to inform you that:
Your account was used to send a huge amount of spam messages during the recent week.
Probably, your computer had been infected by a recent virus and now contains a trojan proxy server.
Please follow our instructions in order to keep your computer safe.
Best regards,
The lists.jboss.org support team.
16 years, 3 months
CEP fusion
by chris richmond
Hello,
I have this test rule that basically fires if a followup reading is not
received with the appropriate value within some time. According to the
fusion docs, simply using:
*not*( FollowUpReading(value == $val, *this* before[0s,5s] $reading ) )
should wait 5 seconds before firing, however this does not work unless I
explicitly also set:
*duration*( 5s )
and if I do that, it seems to wait the 5 seconds, however it always follows
what I put in the duration value and seems to compeltely ignore the time
tolerances I use here.:
$reading : DatarReading($val: value)
*not*( FollowUpReading(value == $val, *this* before[0s,5s] $reading ) )
And if I have different values, it will fire the rule after 2 seconds and
ignore the 5s in the sample below.
Any ideas?
*
rule* "my rule"
*duration*( 2s )
*when
*
$reading : DatarReading($val: value)
*not*( FollowUpReading(value == $val, *this* before[0s,5s] $reading ) )
*then*
System.err.println("did not receive follow up - reading value: " + $val);
*
end
*
16 years, 3 months
Can we use 'from' CE in Decision Tables ?
by groovenarula
Hello all,
Is it possible to define the follow rule in a decision table :
rule "Activate Promotion"
when
l : Line( )
not ( Promotion ( code == "HOTBUY" ) from l.promos )
then
#do some action
end
The rule above works perfectly for what I need when defined in a rule file.
However, when I try to define it in a decision table so that the 'code' can
be feed from a spreadsheet, I use the following values in the rules cells :
RuleTable
HOTBUYS
CONDITION
ACTION
l : Line
not ( Promotion ( code == "$param" ) from l.promos )
System.out.println("$param added");
PROMOTION
PROMOTION
HOTBUY
BESTBUY
I'm getting the following parser errors
[10,17]: [ERR 101] Line 10:17 no viable alternative at input 'Promotion' in
rule "_11" in pattern Line
[10,29]: [ERR 101] Line 10:29 no viable alternative at input 'code' in rule
"_11"
[10,63]: [ERR 102] Line 10:63 mismatched input ')' expecting 'then' in rule
"_11"
java.lang.IllegalArgumentException: Could not parse knowledge.
at
com.sample.DecisionTableTest.readKnowledgeBase(DecisionTableTest.java:85)
at com.sample.DecisionTableTest.main(DecisionTableTest.java:28)
Also in Eclipse IDE, I get the following error :
"Unknown error while parsing. This is a bug. Please contact the Development
team." NewPromotions.xls
Is it possible to use 'from' conditional element in decision tables ? If so,
what am I doing wrong. If not, then what's the best approach to implement
the rule above in a decision table.
I'm running Drools 5.1.0M1 in Eclipse.
Help truly appreciated.
Gurvinder
--
View this message in context: http://n3.nabble.com/Can-we-use-from-CE-in-Decision-Tables-tp67005p67005....
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 3 months
Trivial rule with condition in RHS won't compile, help please
by Barry Kaplan
The following rule:
rule "test" dialect "mvel"
when
eval(true)
then
if (true) {
System.out.println("***")
}
end
Fails with:
java.lang.RuntimeException: Unable to build expression for 'consequence':
was expecting type: java.lang.Object; but found type: void ' if (true) {
System.out.println("***")
}
true
' : [Rule name='test']
I can't for the live of me figure out what mvel is bitching about.
Note that the following does compile:
rule "test" dialect "mvel"
when
eval(true)
then
// if (true) {
System.out.println("***")
// }
end
--
View this message in context: http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-hel...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 3 months
CEP + prevent consequences from triggering multiple times?
by reverselogic
Hi,
I'm trying to write a rule in drools, which triggers once some condition is
active for a specified time interval. For example, if a vehicle is over a
speed limit (100 mph) for 30 seconds, I want to trigger an action. However,
once this rule has fired, I don't want it to fire again until the vehicle
has dropped below the speed limit (and gone over the limit again). The only
way I've managed to model this is by defining two rules; one for determining
when the vehicle is speeding and one for determining when it is not speeding
and using a global object to track the state of the vehicle (see rules
below).
rule "OverSpeedLimit" no-loop true
when
$minSpeed : Double() from accumulate(
$speedingEvent : SpeedingEvent ($speed : speed)
over window:time( 30s )
from entry-point SpeedingStream,
min($speed)
);
eval ($minSpeed > 100.0 && !state.speeding)
then
state.speeding = true
end
rule "!OverSpeedLimit" no-loop true
when
$speedingEvent : SpeedingEvent()
from entry-point SpeedingStream
eval ($speedingEvent.speed <= 100.0)
then
state.speeding = false
end
My questions is: Is there a better way to model the above behaviour,
preferably as a single rule? The reason I ask is because I believe it would
be too complicated for my users to define rules like this. Ideally, I would
like to be able to create a DSL such as: "when Speed is above X for Y
seconds then ..."
Any help greatly appreciated.
Thanks,
Paul
--
View this message in context: http://n3.nabble.com/CEP-prevent-consequences-from-triggering-multiple-ti...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 3 months
unable to resolve Type Declaration class
by richarda
So, my code is doing this:
KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption(EventProcessingOption.STREAM);
KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
try {
File f = new File("/tmp/my.pkg");
InputStream stream = new FileInputStream(f);
if (stream == null) {
jlog.fatal("Unable to find rule pkg");
} else {
jlog.info("adding pkg");
builder.add(ResourceFactory.newInputStreamResource(stream),
ResourceType.PKG);
}
} catch (Exception e) {
e.printStackTrace();
}
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(builder.getKnowledgePackages());
jlog.info("setup creating knowledge session");
ksession = kbase.newStatefulKnowledgeSession();
jlog.info(" setup ksession created");
The pkg was created from Guvnor.
If in the package declaration area in Guvnor, (where you put the import
statements)
If I put
declare Signature
@role ( event )
end
then build the package, save it to disk /tmp/my.pkg
on startup I get:
[#|2009-11-24T14:50:38.944+0000|WARNING|sun-appserver2.1|javax.enterprise.system.stream.err|_ThreadID=12;_ThreadName=pool-1-thread-3;_RequestID=7c35064d-757e-4519-b5eb-433db89e168d;|org.drools.RuntimeDroolsException:
unable to resolve Type Declaration class 'Signature'
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:754)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:515)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
I need to declare 'Signature' as an 'event'
Am I doing this wrong?
If I do this all in Eclipse and load the DRL files manually it all works.
--
View this message in context: http://old.nabble.com/unable-to-resolve-Type-Declaration-class-tp26497326...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 3 months