[rules-users] Cant seem to fire a dynamically added rule

samirsss samirsavla at gmail.com
Mon Mar 10 11:49:38 EDT 2008


Hi Edson,

I tried the exact method you asked me to and seems like now i am getting an
error while I add the rule. Also the rules still dont get fired.

I'm going to send you the code again and maybe you can fix it and send it
back to me after testing that all 3 scenarios for the messageId = Test,
Test2 and Test3 pass.

thanks
Samir

http://www.nabble.com/file/p15950841/TestDynamicRules.zip
TestDynamicRules.zip 

Edson Tirelli-3 wrote:
> 
>    Samir,
> 
>    I had a look at the code you sent me and the problem is that you are
> not
> adding the rule to the rulebase. In your
> ConnectionHandler.testDynamicRules()
> method, you need to do:
> 
>                 ruleBase.addPackage( builder.getPackage() );
> 
>    You probably incurred in this error because you are misusing the
> Package
> objects. You should either remove the whole package from the rule base
> before doing your merge or, what I think is best, create a package with
> the
> "delta" rules you want to add.
>    So, instead of doing:
> 
>               Package defaultPackage = pkg[0];
> 
>    Do:
> 
>               Package defaultPackage = new Package( pkg[0].getName() );
> 
>    So, you are effectively creating a new Package object, but when you add
> it to the rule base, it will be correctly merged into the existing one.
>    This also allows you to AVOID the lock you are doing here:
> 
>                ruleBase.lock(); // no need for that if you use a new
> package
> with the same name
>                packageDescr.addRule( ruleDescr );
>                builder.addPackage(packageDescr);
>                ruleBase.unlock(); // no need for that if you use a new
> package with the same name
> 
>    Hope it helps.
> 
>     Edson
> 
-- 
View this message in context: http://www.nabble.com/Cant-seem-to-fire-a-dynamically-added-rule-tp15810172p15950841.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list