Initiating global in rule
by Fermion
Hi!
I know that this topic has been partially covered in this:
http://www.nabble.com/Initialize-Global-to13388685.html#a13388685
thread.
Nevertheless I think that the geiven answers are only partially satisfying.
Basically the main problem is still unsolved:
One has a global variable inside the DRL and wants to initialize it in a
rule (most likely the initial rule). Althoug several posts in the above
thread point out, that this should be easily possible doing this:
global String test
rule "Initial Rule"
when
then
> session.setGlobal("test", "Hello World");
> System.out.println(test);
will lead to infinite recursions of this initial rule without the code ever
reaching the println()!
I tried several variations of the above. At least of of the ones that have
been used in the aforementioned thread: using no-loop true, using
initialization from Java application using a function call, testing for null
pointer with eval(test == null) and so on.
I'm using Drools 4.0.3 and I have the strong impression that this is a bug,
as all the code examples mentioned in the other thread DO NOT SOLVE the
problem. The recursion still exists.
Thanks for any help in advance!
--
View this message in context: http://www.nabble.com/Initiating-global-in-rule-tp17081556p17081556.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months
Behavior change from Drools 3 to Drools 4 for sequential execution
by mohit churiyal
Hi,
We migrated our project from Drools 3 to Drools 4. We
observed a slight change of behavior in execution of
rules in sequential mode. Suppose we have drl file
with two rules. In first rule we find whether customer
is preferred customer or not and in second rule we use
it to set a discount percentage (portion of drl
provided below). In Drools 3 if we use sequential
execution using rulebase.addPackage(pkg,false) then
both the rules get fired (because first rule updates
customer object). But in Drools 4 if we use sequential
execution (using ruleBaseConf.setSequential(true))
then rule "preferred" gets fired but rule "discount"
doesn't. Apparently the update() in first rule does
not take effect. This is not the behavior one would
expect. Is there any configuration by which same
behavior can be achieved for Drools 4 also? I went
through the user guide and tried few things like
setting
ruleBaseConf.setSequentialAgenda(SequentialAgenda.DYNAMIC)
(and SequentialAgenda.SEQUENTIAL too) but nothing
worked.
rule "preferred"
no-loop true
salience 999999
when
customer:Customer()
eval(customer.getMonthlySalary() > 5000)
then
customer.setType(Customer.PREFERRED);
System.out.println("Updated customer type.");
update(customer);
end
rule "discount"
no-loop true
salience 999998
when
customer:Customer()
eval (
customer.getType().equals(Customer.PREFERRED) )
then
customer.setDiscount(20);
System.out.println("Updated discount percentage.");
update(customer);
end
Regards,
Mohit
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
16 years, 5 months
newbie question on "when" condition syntax
by Richard Bremner
Hi,
say I have a class with two fields, x and y:
public class Test {
int x = 1;
int y = 2;
getters/setters...
}
I would like a rule which fires when y = x + 1
my initial thought would be something like:
rule "Rule 1"
when
test : Test (y == x + 1)
then
System.out.println("Rule 1 matches.");
end
but this is invalid syntax and I can not find any examples of such a rule.
I'm doing my best but reading the manual etc. I'm struggling with the syntax
here and can't figure it out.
any help really appreciated!
16 years, 5 months
OutOfMemory Error - 3500 Rules
by Barry K
Hello,
Has anyone had to resolve out of memory errors with large applications using
moderatly sized rulebases?
Increasing the permGen any higher does not appear to be an option for us.
DROOLS Version 4.01
OutOfMemory Error in PermGen space. Our application has ~5000 classes and
uses ~3500 rules.
Each rules has on average 3 conditions and 2 actions.
The application uses multiple drools rules engines and we load multiple
rulebases into memory.
Would we have a small memory footprint if we combine all of our rules into a
single rulebase and use agenda filtration to execute the appropriate rules?
Right now it is cleaner for us to separate the rulebases.
Current settings-
WAS 6.1 on Solaris
Max Heap 2560
Max PermGen 1024
WAS 6.1 throws startup errors if we increase the Max PermGen above 1024, so
we are looking for alternative solutions.
This seems like a lot of memory for permGen anyway.
Asides:
We do not use WorkingMemoryFileLogger
We have tried using a newer Janino jar but we still encounter the
OutOfMemoryError.
When we have the rules engine running it is extremely fast and we are very
pleased with being able to create our rules in Decision Table format. If
you have any suggestions for the above issue that would be great.
What would you estimate the permGen usage would be on a 3500 rule RuleBase
alone?
--
View this message in context: http://www.nabble.com/OutOfMemory-Error---3500-Rules-tp17019001p17019001....
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months
Re: [rules-users] Newbie need help.
by mashup
Hi Alan,
Just thought I would say I suffered from the same problem and found the
solution hidden in the manual somewhere. The tutorial needs updated....
use:
WorkingMemory workingMemory = ruleBase.newStatefulSession();
and
workingMemory.insert(obj); //instead of assert
cheers
Richard
Alan Jeferson wrote:
>
> Hi all!
>
> After installing Eclipse 3.2.1, I downloaded drools Eclipse IDE 3.0.4
> plugin from JBoss site and put it in the plugins folder of eclipse home
> dir. Then restart eclipse, then File -> New -> Project -> JBoss Rules ->
> New Rules Project. I give a name for the project and click Finish. This
> has create the project with two automatically created source folders
> namely src/java and src/rules. In src/java, I can see
> com.samples.DroolsTest.java which uses the rule Sample.drl in src/rules.
>
> But I obtained some errors in code(the bold lines), like:
>
> - the method newWorkingMemory() is undefined for ruleBase type
> - the method fireAllRules () is undefined for workingMemory type
> - the method addPackage(pkg) is undefined for ruleBase type
>
> //load up the rulebase
> RuleBase ruleBase = readRule();
> WorkingMemory workingMemory =
> ruleBase.newWorkingMemory();
>
> //go !
> Message message = new Message();
> message.setMessage( "Hello World" );
> message.setStatus( Message.HELLO );
> workingMemory.assertObject( message );
> workingMemory.fireAllRules();
> .......................................................
> //get the compiled package (which is serializable)
> Package pkg = builder.getPackage();
>
> //add the package to a rulebase (deploy the rule package).
> RuleBase ruleBase = RuleBaseFactory.newRuleBase();
> ruleBase.addPackage( pkg );
>
> Please tell me what is the problem.
>
> Regards, Alan.
>
>
> ---------------------------------
> Sponsored Link
>
> Degrees online in as fast as 1 Yr - MBA, Bachelor's, Master's, Associate -
> Click now to apply
>
--
View this message in context: http://www.nabble.com/Newbie-need-help.-tp7261678p17026512.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months