Typically you would want to create a rulebase at server load or at the 
application scope and store that rulebase as a singleton. Then at runtime 
get a workingmemory, assert your objects and fire rules.

For our application loading rules into a rulebase takes from 10 to 180 
seconds , but working memory, asserting a few objects and firing the rules 
takes less than 100ms.

-Michael

...... Original Message .......
On Sat, 14 Apr 2007 06:44:15 -0700 (PDT) <[EMAIL PROTECTED]> 
wrote:
>Hello,
>
>  I am using 3.0 RC 2 version of DROOLS in one of our project. (JDK 1.4.2
>and JBoss 3.2.7) When we deployed the application into production, we
>are facing performance issues that seems to be because of class loading
>and GC collection of rule classes that are created at runtime. So I went
>back to the docs and wiki and decided to try the pre-compile and caching
>options. Eventhough i searched the wiki, mailing list archives and doc,
>i was not able to find any advice on how can I do this. Ours is a J2EE
>application and the EJBs call a static method in an helper class which
>will laod the .drl file, build the PackageBuilder and Rulebase, create
>the WorkingMemory and execute the rule.
>
>  Any pointers on how to pre compile the rule and then execute it will be
>really helpful. Below is the current code that executes the rule.
>
>Thanks and Regards,
>
>-- Abhilash.
>
>
>private static RuleResultVO execute( String ruleFile, Object [] objects )
>throws AppException {
>
>
>               RuleResultVO ruleResult = new RuleResultVO();
>               try {
>
>               //read in the source
>               InputStream in = ResourceLoader.getResourceAsStream(ruleFile);
>               Reader reader = new InputStreamReader(in);
>               DrlParser parser = new DrlParser();
>               PackageDescr packageDescr = parser.parse( reader );
>
>               //pre build the package
>               PackageBuilder builder = new PackageBuilder();
>               builder.addPackage( packageDescr );
>               Package pkg = builder.getPackage();
>
>               //add the package to a rulebase
>               RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>               ruleBase.addPackage( pkg );
>
>               //load up the rulebase
>
>               WorkingMemory workingMemory = ruleBase.newWorkingMemory();
>
>               //go !
>
>               for ( int i = 0; i < objects.length; i++ ) {
>                       workingMemory.assertObject( objects[i] );
>               }
>
>
>               workingMemory.assertObject( ruleResult );
>
>               workingMemory.fireAllRules();
>
>
>               }catch( Exception e ) {
>                       e.printStackTrace();
>                       ExceptionUtil.throwAppException( 
> "RuleExecuter.executeRule() :
>Exception Occured :[" +e.getMessage()+"]");
>               }
>
>        return ruleResult;
>       }
>
>
>_______________________________________________
>rules-users mailing list
>[EMAIL PROTECTED]
>https://lists.jboss.org/mailman/listinfo/rules-users
>
>

_______________________________________________
rules-users mailing list
[EMAIL PROTECTED]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to