[rules-users] Drools - Doing Complex Stuff inside a Rule Condition or Consequence

Miguel Fernando Cabrera mfcabrera at gmail.com
Mon Nov 29 13:54:24 EST 2010


Hello everyone

In my company we are planning to use Drools for couple of projects and we
having some questions about the best way to use it

My question is what should be and shouldn't be done inside a Rule
Condition/Consequence. Given that we can write Java directly or call methods
(for example From a Global object in the Working Memory).

Example. Given a Rule that evaluates a generic Object (e.g. Person) have
property set to true. Now, that specific propertie can only be defined for
that Object going to the database (or going to a web service) and fetching
that info. So we have two ways of implementing that:

*Alternative A:*

   - Go to the database and fetch the object property (true/false, a code)
   - Insert the Object in the working memory
   - Evaluate the rule

*Alternative B:*


   - Insert a Global Object that has a method that connects to the database
   and check for the property for the given object.
   - Insert the Object to eval in Working Memory
   - In the rule, call the Global Object and perform the access to the
   database


Which of those is considered better? I really like A,  but sometimes B is
more straightforward, however what would happen if something like a
Exception from the Database is raised?* *I have seen the alternative B
implemented  in the Drools 5.0 Book from Packt Publishing,however they are
doing a mocking and they don't talk about the actual implications of going
to the database at all.

Thank you in advance,

-- 
Miguel Fernando Cabrera Granados
http://mfcabrera.com
"A los hombres fuertes les pasa lo que a los barriletes; se elevan cuando es
mayor el viento que se opone a su ascenso." - José Ingenieros
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101129/1756954b/attachment.html 


More information about the rules-users mailing list