Need advice on asynchronicity
by Chuck Adams
I'm really pretty new to Drools, so bear with me here: I'm trying to
develop some rules for classifying domains as belonging to spammers or
not, based on various test scenarios. Whether to even start these
test scenarios is also controlled by various rules, like occurrences
within a timeframe, so a rule engine seems a natural fit.
So how I might write some rules, off the top of my head:
rule "Lookup A Records"
when
d : Domain( name : n, arecs == null )
not Verdict(domain == d)
then
# lookup_a_records is potentially quite slow
modify( d ) { arecs = lookup_a_records(n) }
end
rule "Spammy host"
when
# isAnyBlacklisted just looks up each record in a DNS zone, very quick
d : Domain( eval( isAnyBlacklisted( d.arecs ) )
not Verdict(domain == d)
then
insert( new Verdict(d, SPAM) )
end
First off, I wouldn't mind being able to refactor those "not
Verdict(domain == d)" conditions out somehow ... agenda groups,
perhaps?
My main problem however is: I want lookup_a_records() to be
asynchronous. It's potentially very slow, and I have hundreds of
other domains to check (I have other scenarios that are slower than
mere DNS lookups, this is just an example). Just to add to the fun,
there can only be so many queries outstanding at any one time, so I'm
looking at using a queue somewhere. I'm thinking I could lose the
modify in the first rule, and make lookup_a_records schedule some
asynchronous call through a ThreadPoolExecutor that modifies the fact
-- hopefully directly, but is a session threadsafe?
Are there any examples I can look at where the RHS modifies and
inserts facts asynchronously?
Chuck
17 years
RE: [rules-users] Rules syntax question using hashmap
by Greg Barton
It looks like you want to use null safe bean navigation in mvel 2:
http://mvel.codehaus.org/MVEL+2.0+Property+Navigation
try this:
$f : Fact(details.?END_MATCH == true, details.?WINNER == "AWAY")
I have no idea if it will work, as the null safe ? example is for accessing bean properties, but it's worth a try. It's also MVEL 2.0, so will only work with drools 5.
--- On Thu, 2/26/09, Zevenbergen, Alex <azevenbergen(a)paddypower.com> wrote:
> From: Zevenbergen, Alex <azevenbergen(a)paddypower.com>
> Subject: RE: [rules-users] Rules syntax question using hashmap
> To: greg_barton(a)yahoo.com
> Date: Thursday, February 26, 2009, 11:30 AM
> So that doesn't solve the problem of null params in the
> hashmap?
>
> Do you know if it is possible?
>
> Also is there a good place for rules documentation and
> examples as all
> the examples I can find are fairly simply and
> one-dimensional
>
> -----Original Message-----
> From: Greg Barton [mailto:greg_barton@yahoo.com]
> Sent: 26 February 2009 17:26
> To: Zevenbergen, Alex
> Subject: RE: [rules-users] Rules syntax question using
> hashmap
>
> Ah. That's because drools is expecting
> "details" to be an object type.
> Rule conditions take the following form:
>
> ObjectType(property == value, anotherProperty >
> anotherValue, ...)
>
> So, for a condition like this...
>
> details(fact == $f, name == "END_MATCH", value ==
> true)
>
> ...you would need a class definition like this:
>
> class details {
> Fact fact;
> String name;
> boolean value;
> }
>
> And an object of type "details" would need to be
> inserted into working
> memory for the condition to possibly match.
>
> --- On Thu, 2/26/09, Zevenbergen, Alex
> <azevenbergen(a)paddypower.com>
> wrote:
>
> > From: Zevenbergen, Alex
> <azevenbergen(a)paddypower.com>
> > Subject: RE: [rules-users] Rules syntax question using
> hashmap
> > To: greg_barton(a)yahoo.com, "Rules Users
> List"
> <rules-users(a)lists.jboss.org>
> > Date: Thursday, February 26, 2009, 11:14 AM
> > Hi,
> > I get the following error: Unable to resolve
> ObjectType
> > 'details'
> >
> > I've tried different variations (getDetails etc)
> but
> > 'details is my
> > attribute name and doesn't seem to be picked up!
> >
> > alex
> > -----Original Message-----
> > From: rules-users-bounces(a)lists.jboss.org
> > [mailto:rules-users-bounces@lists.jboss.org] On Behalf
> Of
> > Greg Barton
> > Sent: 26 February 2009 17:04
> > To: Rules Users List
> > Subject: Re: [rules-users] Rules syntax question using
> > hashmap
> >
> > Can you provide any info on why the third option
> > doesn't work?
> >
> > --- On Thu, 2/26/09, Zevenbergen, Alex
> > <azevenbergen(a)paddypower.com>
> > wrote:
> >
> > > From: Zevenbergen, Alex
> > <azevenbergen(a)paddypower.com>
> > > Subject: [rules-users] Rules syntax question
> using
> > hashmap
> > > To: rules-users(a)lists.jboss.org
> > > Date: Thursday, February 26, 2009, 10:45 AM
> > > Hi all,
> > >
> > >
> > >
> > > Im using an object called 'Fact' this
> object
> > has
> > > one attribute that is a
> > > hashmap 'details'
> > >
> > >
> > >
> > > I know there are several ways to access the
> parameters
> > in
> > > the hashmap
> > >
> > >
> > >
> > > $f : Fact()
> > >
> > > eval
> > ($f.getDetails().get("END_MATCH").toString()
> > > == "true" &&
> > >
> $f.getDetails().get("WINNER").toString() ==
> > > "HOME")
> > >
> > >
> > >
> > > $f : Fact(details.END_MATCH ==
> true,details.WINNER ==
> > > "AWAY")
> > >
> > >
> > >
> > > $f : Fact()
> > >
> > > details(fact == $f, name ==
> "END_MATCH",
> > value ==
> > > true)
> > >
> > >
> > >
> > >
> > >
> > > I was told the third option works but it
> doesn't
> > for
> > > me!
> > >
> > >
> > >
> > > Anyway my question is: Is there anyway for these
> sort
> > of
> > > rules to not
> > > through an exception if any of the named
> parameters
> > > aren't on the
> > > hashmap 'details'?
> > >
> > >
> > >
> > > Ideally the rule would simply not fire if it
> looked
> > for a
> > > key that
> > > wasn't there!
> > >
> > >
> > >
> > > Any info much appreciated
> > >
> > >
> > >
> > > Alex
> > >
> > >
> > >
> > >
> > >
> >
> ________________________________________________________________________
> > > Privileged, confidential and/or copyright
> information
> > may
> > > be contained in this communication. This e-mail
> and
> > any
> > > files transmitted with it are confidential and
> > intended
> > > solely for the use of the individual or entity to
> whom
> > they
> > > are addressed. If you are not the intended
> addressee,
> > you
> > > may not copy, forward, disclose or otherwise use
> this
> > e-mail
> > > or any part of it in any way whatsoever. To do so
> is
> > > prohibited and may be unlawful. If you have
> received
> > this
> > > email in error
> > > please notify the sender immediately.
> > >
> > > Paddy Power PLC may monitor the content of e-mail
> sent
> > and
> > > received for the purpose of ensuring compliance
> with
> > its
> > > policies and procedures.
> > >
> > > Paddy Power plc, Airton House, Airton Road,
> Tallaght,
> > > Dublin 24 Registered in Ireland: 16956
> > >
> >
> ________________________________________________________________________
> > _______________________________________________
> > > rules-users mailing list
> > > rules-users(a)lists.jboss.org
> > >
> https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> ________________________________________________________________________
> > Privileged, confidential and/or copyright information
> may
> > be contained in this communication. This e-mail and
> any
> > files transmitted with it are confidential and
> intended
> > solely for the use of the individual or entity to whom
> they
> > are addressed. If you are not the intended addressee,
> you
> > may not copy, forward, disclose or otherwise use this
> e-mail
> > or any part of it in any way whatsoever. To do so is
> > prohibited and may be unlawful. If you have received
> this
> > email in error
> > please notify the sender immediately.
> >
> > Paddy Power PLC may monitor the content of e-mail sent
> and
> > received for the purpose of ensuring compliance with
> its
> > policies and procedures.
> >
> > Paddy Power plc, Airton House, Airton Road, Tallaght,
> > Dublin 24 Registered in Ireland: 16956
> >
> ________________________________________________________________________
>
>
>
>
> ________________________________________________________________________
> Privileged, confidential and/or copyright information may
> be contained in this communication. This e-mail and any
> files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they
> are addressed. If you are not the intended addressee, you
> may not copy, forward, disclose or otherwise use this e-mail
> or any part of it in any way whatsoever. To do so is
> prohibited and may be unlawful. If you have received this
> email in error
> please notify the sender immediately.
>
> Paddy Power PLC may monitor the content of e-mail sent and
> received for the purpose of ensuring compliance with its
> policies and procedures.
>
> Paddy Power plc, Airton House, Airton Road, Tallaght,
> Dublin 24 Registered in Ireland: 16956
> ________________________________________________________________________
17 years
RE: [rules-users] Rules syntax question using hashmap
by Zevenbergen, Alex
Hi,
I get the following error: Unable to resolve ObjectType 'details'
I've tried different variations (getDetails etc) but 'details is my
attribute name and doesn't seem to be picked up!
alex
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Greg Barton
Sent: 26 February 2009 17:04
To: Rules Users List
Subject: Re: [rules-users] Rules syntax question using hashmap
Can you provide any info on why the third option doesn't work?
--- On Thu, 2/26/09, Zevenbergen, Alex <azevenbergen(a)paddypower.com>
wrote:
> From: Zevenbergen, Alex <azevenbergen(a)paddypower.com>
> Subject: [rules-users] Rules syntax question using hashmap
> To: rules-users(a)lists.jboss.org
> Date: Thursday, February 26, 2009, 10:45 AM
> Hi all,
>
>
>
> Im using an object called 'Fact' this object has
> one attribute that is a
> hashmap 'details'
>
>
>
> I know there are several ways to access the parameters in
> the hashmap
>
>
>
> $f : Fact()
>
> eval ($f.getDetails().get("END_MATCH").toString()
> == "true" &&
> $f.getDetails().get("WINNER").toString() ==
> "HOME")
>
>
>
> $f : Fact(details.END_MATCH == true,details.WINNER ==
> "AWAY")
>
>
>
> $f : Fact()
>
> details(fact == $f, name == "END_MATCH", value ==
> true)
>
>
>
>
>
> I was told the third option works but it doesn't for
> me!
>
>
>
> Anyway my question is: Is there anyway for these sort of
> rules to not
> through an exception if any of the named parameters
> aren't on the
> hashmap 'details'?
>
>
>
> Ideally the rule would simply not fire if it looked for a
> key that
> wasn't there!
>
>
>
> Any info much appreciated
>
>
>
> Alex
>
>
>
>
>
________________________________________________________________________
> Privileged, confidential and/or copyright information may
> be contained in this communication. This e-mail and any
> files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they
> are addressed. If you are not the intended addressee, you
> may not copy, forward, disclose or otherwise use this e-mail
> or any part of it in any way whatsoever. To do so is
> prohibited and may be unlawful. If you have received this
> email in error
> please notify the sender immediately.
>
> Paddy Power PLC may monitor the content of e-mail sent and
> received for the purpose of ensuring compliance with its
> policies and procedures.
>
> Paddy Power plc, Airton House, Airton Road, Tallaght,
> Dublin 24 Registered in Ireland: 16956
>
________________________________________________________________________
_______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
________________________________________________________________________
Privileged, confidential and/or copyright information may be contained in this communication. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended addressee, you may not copy, forward, disclose or otherwise use this e-mail or any part of it in any way whatsoever. To do so is prohibited and may be unlawful. If you have received this email in error
please notify the sender immediately.
Paddy Power PLC may monitor the content of e-mail sent and received for the purpose of ensuring compliance with its policies and procedures.
Paddy Power plc, Airton House, Airton Road, Tallaght, Dublin 24 Registered in Ireland: 16956
________________________________________________________________________
17 years
Rules syntax question using hashmap
by Zevenbergen, Alex
Hi all,
Im using an object called 'Fact' this object has one attribute that is a
hashmap 'details'
I know there are several ways to access the parameters in the hashmap
$f : Fact()
eval ($f.getDetails().get("END_MATCH").toString() == "true" &&
$f.getDetails().get("WINNER").toString() == "HOME")
$f : Fact(details.END_MATCH == true,details.WINNER == "AWAY")
$f : Fact()
details(fact == $f, name == "END_MATCH", value == true)
I was told the third option works but it doesn't for me!
Anyway my question is: Is there anyway for these sort of rules to not
through an exception if any of the named parameters aren't on the
hashmap 'details'?
Ideally the rule would simply not fire if it looked for a key that
wasn't there!
Any info much appreciated
Alex
________________________________________________________________________
Privileged, confidential and/or copyright information may be contained in this communication. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended addressee, you may not copy, forward, disclose or otherwise use this e-mail or any part of it in any way whatsoever. To do so is prohibited and may be unlawful. If you have received this email in error
please notify the sender immediately.
Paddy Power PLC may monitor the content of e-mail sent and received for the purpose of ensuring compliance with its policies and procedures.
Paddy Power plc, Airton House, Airton Road, Tallaght, Dublin 24 Registered in Ireland: 16956
________________________________________________________________________
17 years
EulerGUI released - IDE for semantic Web with Drools engine and Drools export
by Jean-Marc Vanel
Hi
As some of you know, I'm using Drools as an engine for N3 logic (
http://www.w3.org/2000/10/swap/doc/Rules) .
N3 is a language equivalent to Semantic Web's RDF language, but much easier
to read and write by hand.
Moreover, N3 has, on top of RDF, an extension for rules, e.g. :
{ ?x parent ?y } => { ?y child ?x }.
Among many other vocabularies searchable on search site Swoogle (
http://swoogle.umbc.edu/), there is OWL, (OWL Web Ontology Language) that
allows to express in RDF, and thus in N3, rich models with classes,
properties, inheritance and constraints.
So in summary, N3 is a user-friendly language allowing to express facts,
class and properties, and rules.
So what does that bring for Drools users ?
One use case :
- open any number of RDF / OWL / N3 documents
- test and debug the rules using 3 rule engines (Drools, Euler, CWM)
- export all that project as a set of Drools packages, plus the facts in
XMLEncoder format ( by clicking on File / "Export as Drools" )
You can also use standard Semantic Web tools such as Protégé and Swoop to
edit and visualize RDF and OWL files.
Moreover, there are, as part of the Euler project, a library of N3 rules
that implement the logic of OWL and RDF Schema (transitive property,
inheritance, etc), and other goodies, see:
http://eulersharp.svn.sourceforge.net/viewvc/eulersharp/trunk/2003/03swap...
I translate N3 logic into Drools language, using just two classes
corresponding to Triple (statement) ( explanations here :
http://eulergui.svn.sourceforge.net/viewvc/eulergui/trunk/eulergui/html/d...).
Download from
https://sourceforge.net/projects/eulergui
Manual here:
http://eulergui.svn.sourceforge.net/viewvc/eulergui/trunk/eulergui/html/d...
Enjoy !
I've been working on this for several months, so it's beginning to
stabilize. But the rich set of built-in functions for other N3 engines is
still missing, with a few exceptions.
I'm using this framework currently to generate GUI's from domain models (
rules are here : http://deductions.svn.sourceforge.net/viewvc/deductions/n3/).
You will be glad to read that it runs around 2 seconds including
compilation, compared to the other engine (in Prolog) I use, which need
hundreds of seconds (actually a high complexity). A forward chaining engine
seems to make sense for such a constructive task.
I also wrote a How To about what I do currently with EulerGUI :
Deduction project - Java Swing application generator from OWL model and N3
logic rules
http://deductions.svn.sourceforge.net/viewvc/deductions/html/GUIgenerator...
Deduction project is work in progress.
--
Jean-Marc Vanel
http://jmvanel.free.fr/
17 years
Help with using Agenda filter and firelimit with Web Guided decision tables
by guyt1122@aim.com
Hi,
I'm using Drools 5.0M5 and Web Guided decision tables. What I want to be able to do is to create several decision tables under one package and then using an Agenda filter and firelimit option to fire one rule from a single decision table that I'm filtering.
What I did to try and accomplish this is the following.? I notice that each row in the decision table has a rule name that matches the following format: "Row 1 DecisionTableName", "Row 2 DecisionTableName" ... "Row N DecisionTableName", so I create a RuleNameEndsWithAgendaFilter agenda filter to only accept rules that ends with "DecisionTableName". Then I call on the StatefulSession.fireAllRules(AgendaFilter, fireLimit) with my agenda filter and a firelimit of 1.
What I'm noticing is some inconsistent behavior were the logic would work sometimes and not other times.? It seems to always works if there is a single decision table under the package.? After debuging the StatefuleSession.fireAllRules(AgendaFilter, firelimit), I tracked down the issue to the way the firelimit count updated in the "DefaultAgenda.fireAllRules(AgendaFilter, fireLimit)" and with the "DefaultAgenda.fireNextItem(AgendaFilter)".
I may have misunderstood what the firelimit meant but it seems like the while loop in the fireAllRules always decrements the firelimit count regardless if the DefaultAgenda.fireNextItem(AgendaFilter) calls the fireActivation method or the fireActivationCancelled method.? I would perfer the firelimit count to only get decremented if the fireNextItem results in a fireActivation method call and I think the logic will work for my scenario.? Looking at the documenation, it look like the logic is geared towards focusing agenda groups, but I do not want to have maintain a agenda group column on my decision tables.? I want each decision table to be an agenda group automagically.
I have included the following code showing the firelimit is always updated in the while loop below:
??? public int fireAllRules(AgendaFilter agendaFilter,
??????????????????????????? int fireLimit) {
??????? this.halt.set( false );
??????? int fireCount = 0;
??????? while ( continueFiring( fireLimit ) && fireNextItem( agendaFilter ) ) {
??????????? fireCount++;
??????????? fireLimit = updateFireLimit( fireLimit );
??????????? this.workingMemory.executeQueuedActions();
??????? }
??????? if ( this.focusStack.size() == 1 && getMainAgendaGroup().isEmpty() ) {
??????????? // the root MAIN agenda group is empty, reset active to false, so it can receive more activations.
??????????? getMainAgendaGroup().setActive( false );
??????? }
??????? return fireCount;
??? }
Thanks,
Guy
17 years
Problem with viewing the Business Rule Assets under the Rules Package in Drools Guvnor
by guyt1122@aim.com
Hello,
I have noticed a strange behavior with the Drools Guvnor where I can
not see any of my web guided decision table from the Rules Package
"Business Rule Asset" view.? I can navigate to this decision table
using the "Assets View" and when I click on the "more info" button the addition information on the left hand
side of the decision table
clearly shows that the asset belongs to the expected package that I can
not see it from.? I have tried to archive the decision table and it
does not show up in the archives.? I have tried changing the package
name on the asset and then I tried to navigate to the asset from the
other package, I still can not see it.? Note, the package somehow gets disconnects from the package after a restart the app server. The other strange behavior is that I can make changes to the decision table and then rebuild the packages and the changes show in the package source.? I just can not see the decision table by from the package...
Note, I have configured JackRabbit to store the repository in a database along with a journal node for clustering.
Environment Details:
+ App Server - JBoss 4.0.3.sp1
+ Drools 5.0M5
+ Database - Microsoft Sql Server
+ JackRabbit Repo - Configured to use a Jndi data source configured in JBoss.
Any advise would be appreciated.
Thanks,
-GuyT1122
17 years
Error creating field accessors ... in Guvnor
by J Michael Dean
Started new model in Guvnor and declared two fact types. Nothing else
involved. Source code that is provided from Guvnor is shown below.
But when I try to build the package, or create a scenario, I get error
[package configuration problem] Error creating field accessors for
"Hemodynamics" for type "Hemodynamics" and similar error for the other
object. Here is the source that is available after buildling the
snapshot (even though it refused to build):
package vasoactive.decision
declare Hemodynamics
SystolicBP: Integer
DiastolicBP: Integer
CentralVenousPressure: Integer
CurrentDopamineDosePerKg: java.math.BigDecimal
end
declare HemodynamicDecisionState
DetectedHypotension: Boolean
DetectedLowCVP: Boolean
DetectedNormotension: Boolean
DetectedHypertension: Boolean
RecommendedStartDopamine: Boolean
RecommendedDecreaseDopamine: Boolean
RecommendedIncreaseDopamine: Boolean
end
Any assistance greatly appreciated.
17 years