On 12/18/2012 07:46 PM, jgauss wrote:
Hi,
I have a doubth about rules.
Can I to evaluate a rule using a external source?, for instance a database
or always is it with a statics conditions?
Hi,
I think best practice is to insert a global, for instance, if you have
an entity of the class:
|class AGlobalDataSource||{||
||
|| public Collection<SomeData> getSomeDataFeed||{||
|| ...||
|| }||
||}|
Then you insert the data source into the working memory global:
|
AGlobalDataSource dataSource = new AGlobalDataSource();
WorkingMemory wm = rulebase.newStatefulSession();
wm.setGlobal( "dataSource", dataSource );
|
Then you should be able to read from that global's properties, like:
|global AGlobalDataSource dataSource;||
||
||rule "test from data source"||
|| when||
|| SomeData( ) from dataSource.someDataFeed||
|| then||
|| // action||
||end|
Bear in mind that the engine does not know if any data from the data
source is changed and the rules need to be re-evaluated.
Regards,
Willem
Thanks.
--
View this message in context:
http://drools.46999.n3.nabble.com/Evaluating-Rules-tp4021241.html
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users