Sure, I agree, this would be an example:-
rule "Family smurf"
when
MyFact( smurf == "pupa" )
ExternalObject( ) from placeHolder.namedQuery("Smurfs")
then
//Do something
end
If MyFact is updated in other rules the list will be refreshed "from" the
named query.
So the preference might be to load the Objects into WM first:-
rule "bootstrap"
salience -100
when
$list : List( ) from placeHolder.namedQuery("Smurfs")
then
for(ExternalObject o : $list ) {
insert( o );
}
end
rule "Family smurf"
when
MyFact( smurf == "pupa" )
ExtenalObject( )
then
//Do something
end
You could also have a layer of caching between the rules and RDBMS too; so
your only performing a read from cache with the "from" keyword and not RDBMS
itself.
How you choose is obviously up to you and the volatility of your data read
from RDBMS.
2011/2/14 Mauricio Salatino <salaboy(a)gmail.com>
Beware with the use of the FROM Conditional Element, because if you
are
using another fact that doesn't come from the DB and you change them, the
FROM CE will be continuously evaluated causing the execution of tons of
queries multiple times.
My two cents.
Greetings
2011/2/14 Michael Anstis <michael.anstis(a)gmail.com>
You can access Objects from external resources using the "from" keyword (in
> fact the use of this with Hibernate named queries is a documented use-case,
> IIRC).
>
> The Objects are not however inserted into WorkingMemory using "from" are
> should therefore be time-constant as their properties will not be included
> in truth maintenance.
>
> If you require the Objects as Facts in WorkingMemory for the inference
> engine to reason with, you can write rules using "from" that insert into
> WorkingMemory.
>
>
> On 14 February 2011 11:27, hyjshanghai <hyjshanghai(a)gmail.com> wrote:
>
>>
>> As far as I know, Drools can only reason over facts in the working
>> memory. It
>> can not directly "select" from RDBMS. You have to load in all data
items
>> from the database and validate them in memory by Drools.
>> --
>> View this message in context:
>>
http://drools-java-rules-engine.46999.n3.nabble.com/Applying-rules-on-the...
>> Sent from the Drools - User mailing list archive at
Nabble.com.
>> _______________________________________________
>> 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
>
>
--
- CTO @
http://www.plugtree.com
- MyJourney @
http://salaboy.wordpress.com
- Co-Founder @
http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users