Using drools.halt() is not considered a good practice at all. I would
recommend you to read this post:
http://ilesteban.wordpress.com/2012/11/16/about-drools-and-infinite-execu...
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Blog @
http://ilesteban.wordpress.com
On Fri, Dec 7, 2012 at 8:59 AM, Hushen Savani
<hushen.savani(a)elitecore.com>wrote:
Hi,****
** **
I have a simple rule as following:****
** **
*import java.util.HashMap;*
* *
*rule "first"*
*when*
* a : CrestelRuleModel( $hmap : singleHashMap!=null);*
*then*
* System.out.println("Old Map: " + $hmap);*
* HashMap mapp = new HashMap();*
* mapp.put("hello", "world");*
* a.setSingleHashMap(mapp);*
* System.out.println("New Map: " + a.getSingleHashMap());*
* update(a);*
*end;*
** **
When I invoke the rule from my client, the rule is executed *infinitely*.*
***
** **
So, I have placed a “*drools.halt()*” before “*end*” statement of above
rule. So, it stopped executing infinitely as I wanted. But *is it a good
practice?*****
** **
Now, I want my input to be filtered by *two rules*, so I have placed
rules like following:****
** **
*import java.util.HashMap;*
* *
*rule "first"*
*when*
* a : CrestelRuleModel( $hmap : singleHashMap!=null);*
*then*
* System.out.println("Old Map: " + $hmap);*
* HashMap mapp = new HashMap();*
* mapp.put("hello", "world");*
* a.setSingleHashMap(mapp);*
* System.out.println("New Map: " + a.getSingleHashMap());*
* update(a);*
* drools.halt();*
*end;*
* *
*rule "second"*
*when*
* b : CrestelRuleModel( $hmap2 : singleHashMap!=null);*
*then*
* System.out.println("Old Map2: " + $hmap2);*
* HashMap mapp2 = new HashMap();*
* mapp2.put("hello2", "world2");*
* b.setSingleHashMap(mapp2);*
* System.out.println("New Map2: " + b.getSingleHashMap());*
* update(b);*
* drools.halt();*
*end;*
** **
But in above case, *only the “second” rule executes*. What to do in
order to execute both the rules without any infinite loop?****
** **
Kindly share some pointers on this. Thanks.****
** **
** **
*PS*: *CrestelRuleModel* is my POJO model having following fields,****
* *
*public* *class* CrestelRuleModel {****
****
*private* *ArrayList* arrayListOfHashMap;****
*private* *HashMap* singleHashMap;****
*private* Object object;****
*private* String remarks;****
** **
//Getters and Setters****
** **
}****
** **
Best Regards****
*Hushen Savani* | Crestel Billing****
[image: ecTag]****
** **
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users