Question about timing rules
by Bagwell, Allen F
Another noob question:
Is there a generally understood way of implementing the concept of a time interval rule?
That is, lets say I have a Drools-enabled client which is constantly receiving information from outside resources. Most of this data (and the consequences of its changes) is time sensitive, so I'm calling the fireAllRules() method in a loop every minute.
And now, let's say I have a rule that in addition to being driven by incoming data changes has to be linked to a repeating clock interval or synched with wall time such that the rule only activates and fires if the data meets certain parameters AND it's been exactly 1 hour since the last check or that it will fire at the top of every wall time hour (1 PM, 2PM, 3 PM, etc.).
Furthermore, timing may change. A successful rule activation and firing might do something like "now change this timing so that for the next 24 hours, this rule must be examined every 30 minutes instead of every hour".
My initial reading of the Drools documetation I came across the Duration, and Date-* keywords. Their descriptions didn't seem to fit the bill.
I ask this because our old rules engine software that has been retired to obsolescence allowed this kind of thing to be easily set up. Coming at it in the Drools world seems a lot more challenging.
Thoughts? Examples?
-Allen
16 years, 5 months
Converting to XML error, <from> tag not handled?
by PassiveReality
Hi
I'm currently trying to create a simple example in converting a DRL rule
into an XML rule and compiling that but it seems that the XML conversion is
not working correctly or have I done something wrong? Has anyone noticed
this problem too?
public static String convertDrlToXmlRule(String drlRule) throws
DroolsParserException
{
DrlParser parser = new DrlParser();
PackageDescr descr = parser.parse(drlRule);
// Dump to xml rule.
XmlDumper dumper = new XmlDumper();
return dumper.dump(descr);
}
the code above converts a drlRule and dumps out an XML format.
My example drl rule (this compiles fine):
public static String exampleRule = "package com.rules;" +
"import com.rules.my.test.Message;" +
"import com.rules.my.test.SubMessage;" +
"import com.rules.my.test.SubSubMessage;" +
"rule \"exampleRule\"" +
" dialect \"mvel\"" +
" when" +
" Message( $subMessage :
subMessage)\n" +
" SubMessage( $subSubMessage :
subSubMessage) from $subMessage\n" +
" SubSubMessage( message ==
\"SubSub\") from $subSubMessage\n" +
" \nthen\n" +
" System.out.println( $subMessage );"
+
" end";
What comes out:
<?xml version="1.0" encoding="UTF-8"?>
<package name="com.rules"
xmlns="http://drools.org/drools-4.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
<import name="com.rules.my.test.Message" />
<import name="com.rules.my.test.SubMessage" />
<import name="com.rules.my.test.SubSubMessage" />
<rule name="exampleRule ">
<rule-attribute name="dialect" value="mvel" />
<lhs>
<pattern object-type="Message" >
<field-binding field-name="subMessage" identifier="$subMessage" />
</pattern>
<pattern object-type="SubMessage" >
<field-binding field-name="subSubMessage"
identifier="$subSubMessage" />
<field-binding field-name="subSubMessage"
identifier="$subSubMessage" />
<from>
<expression> $subMessage </expression>
</from>
</pattern>
<pattern object-type="SubSubMessage" >
<field-constraint field-name="message">
<literal-restriction evaluator="==" value="SubSub" />
</field-constraint>
<field-constraint field-name="message">
<literal-restriction evaluator="==" value="SubSub" />
</field-constraint>
<from>
<expression> $subSubMessage </expression>
</from>
</pattern>
</lhs>
<rhs>
System.out.println( $subMessage );
</rhs>
</rule>
</package>
If you noticed above it comes out with duplicate field-constaints for
pattern SubSubMessage?? However, thats not a big problem, when I try to
compile the rule in XML format it throws:
org.xml.sax.SAXParseException: <from> is after an invalid element:
org.drools.xml.Handler
at org.drools.xml.XmlPackageReader.validate(XmlPackageReader.java:506)
at
org.drools.xml.XmlPackageReader.startElement(XmlPackageReader.java:394)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
Source)
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.drools.xml.XmlPackageReader.read(XmlPackageReader.java:321)
at org.drools.xml.XmlPackageReader.read(XmlPackageReader.java:247)
Any suggestions in what I am doing wrong?
Cheers,
Le.
16 years, 5 months
How to Configure Hibernate and use in Drools
by RAJA SEKHAR REDDY MAYALURU
hi ,
i need to connect to data from a .drl file from a rule . i need to get the
dynamic data from DB to frmae a rule .
I have seen that Drools support Hibernate .
so how can i connect to DB from a drl to DB using hibernate .
i need to have dynamic (data ) rules in my drl file .
we can configure hibernate on top of pojo , my main intrest is to know how
to invoke hibernate from a drl file .
how to execute named queries in the rule project .
please send me the steps to configure hibernate and use it in rules project
.
thanks for the help in advance
regards ,
Sekhar .
16 years, 5 months
Rule Agent Performance : BRMS or pkg file ?
by Cabou, Carl
Hi all,
I'm using Drools 4.0.7.
I use the Drools api in my application with the rule Agent as describe
in the section 9.4.4.1 of the documentation and it works fine.
Since our application is running under weblogic 8.1, we must use JBoss
for BRMS because weblogic 8.1 is not java5 compliant, but I don't want
to use multiple app servers.
So the question is : what is best for performance ? use the BRMS at
runtime (< url > property) on JBoss or use only packages files on disk
(< file > property).
Anyway I will do perf benchmarks, I'm assuming it is better with package
files but I'd like to have some feedback before...
Regards,
Carl.
16 years, 5 months
Possible OSWorkflow Merger
by Mark Proctor
I just wanted to give the Drools community a heads-up that the
OSWorkflow community might be merging with us - not confirmed yet, but
their project lead is keen. Our unified process work has matured and we
are now very close to having a migration path for OSWorkflow users, who
are keen to migrate to an actively maintained project. We've spoken to
Diego Naya Lazo, the project lead and author of the OSWorkflow Book
http://www.infoq.com/articles/naya-lazo-osworkflow, and he is liasing
with his community to see if they are happy to move forward with this.
The Drools process stuff also needs a name, as sub project - remember we
have total unification and integration between the rules and process
(see blog http://blog.athico.com/search/label/Rule%20Flow). So we can
either go down generic routes - Drools Flow, Drools Rules, Drools
Events. Or have something a bit more fun Drools Meastro, Drools X,
Drools Fusion - X is there sa I don't have a fun name for the rule part.
The idea is we will split the manual up into separate books that will
start from the understanding of a person from that discipline, before
jumping deep into how the techs are integrated.
This is huge news and puts us firmly onto the path of a unified
modelling environment, and hopefully an end to the days of having to
choose and purchase separate and poorly integrated products for rules,
processes and complex event processing.
Mark
16 years, 5 months
Consequence Restriction
by Markus Helbig
Hi,
i have on DSL and several DSRL files. What i want to do is to restrict
the usage of consequence parts. Means
I have to possible kind of objects in my workingmemory, e.g. Item1 and Item2.
Item1 has a methode setValue1(), and Item2 setValue2()
my DSL has to possible consequence lines
[consequence][]set value1 {value} for {item}={item}.setValue1({value});
[consequence][]set value2 {value} for {item}={item}.setValue2({value});
so now you can use both consequences for the objects but you
shouldn't. currently at runtime an exception will occur. Is it
possible to check this fault at compile time?
Cheers
Markus
16 years, 5 months
question on rule efficiency
by Barry Kaplan
When the value of a property is compared across two instances, is it better
to create variables for the properties, or is using the object.property for
the comparison equivalent?
Here's an example: I need to match based on the strikePrice property. Is
either version better than the other?
version 1)
putContract : OptionInstrument(
optionType == OptionType.PUT)
callContract : OptionInstrument(
optionType == OptionType.CALL,
strikePrice > putContract.strikePrice)
// compare using navigation
version 2)
putContract : OptionInstrument(
optionType == OptionType.PUT,
putStrikePrice : strikePrice)
// delcare the variable
callContract : OptionInstrument(
optionType == OptionType.CALL,
strikePrice > putStrikePrice)
// compare using variable
--
View this message in context: http://www.nabble.com/question-on-rule-efficiency-tp17672843p17672843.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months
Drools 4.0.7 BRMS issues with empty custom_nodetypes.xml
by simonwck@netscape.net
Greeting,
I deployed Drools 4.0.7 BRMS war file to GlassFish V2 on my Windows XP
SP2 laptop successfully, but could not start BRMS from GlassFish. I got
http 503 service not available error. The Java stacktrace indicated
Jackrabbit failed to read custom node type definitions stored in custom_nodetypes.xml. Then I checked the custom_notetypes.xml; it is empty, zero size.
Any idea on how I can workaround it, or will a dummy/smaple
custom_nodetypes.xml work? Thank you and appreciated any input you may
have.
Regards,
Simon
16 years, 5 months
What is done when inserting
by Mounir Chattou
Hi,
When you insert an object, are all the properties checked one by one for
pattern matching ?
Or what is done ?
I'm using Drools for a selection process and I have very bad performances
because of it: 75 ms for the first insertion ... (an object with 20
properties), and totally 90 ms for 5 insertions of the same kind of objects.
Compared with java code : 1ms ...
But it's clear it is easier to write rules than java code.
--
View this message in context: http://www.nabble.com/What-is-done-when-inserting-tp17670106p17670106.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months