you may reconsider the structure of the rules.

Push instead of pull. This means compare the file time or content to the database and only recreate rules that have modified. This way you can update the serialized packages where appropriate.

Without knowing what your rules looks like I can offer the following:
Consider using decision tables where the rules are similar but based on data.
Consider having rules that to retrieve the data instead of rules generated from the data.
Consider that some of the data may be facts and not rules.

If you can generate rules from data then you can write rules that use the data as facts.

On 07/01/2011 16:16, Piotr Jedrychowski wrote:
Part:
knowledgeBuilder.add(resource, ResourceType.DRL);
is the most expensive part of my source code - rest of instructions are nothing when you compare them to above line.

I cannot serialize the compiled rule packages because rules are generated from data read from database and this data isn't static. Data is generated before loading rules from files that user can change - so I have to do this:
1) read files (which could be changed by user since last JBoss startup)
2) process files and generate rows for database
3) get rows from database and generate rules for Drools

Rules aren't stored directly into database - I wasn't accurate in my previous e-mail. - sorry.



On 2011-01-07 14:00, Corneil du Plessis wrote:
You should only repeat

knowledgeBuilder.add(resource, ResourceType.DRL);

for each rule.

The next thing you can do is to serialize the compiled rule packages.

You should also consider using Guvnor to manage your rules.

On 07/01/2011 14:05, Piotr Jedrychowski wrote:
Hello.

I'm loading a big amount of rules during starting of JBoss (20000 rules). All rules (in string format) are available before JBoss startup - they are stored into database. Rules are loaded one by one and it takes about 90 minutes. I want to speed up this process. Is there something like "bulk load" for inserting rules into knowledge base or another smart way to fast loading a big amount of rules?

I'm using:
1) Drools 5.1
2) JBoss 4.2.3

My source code looks like this:

String rule = ...
Resource resource = ResourceFactory.newReaderResource(new StringReader(rule));
KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
knowledgeBuilder.add(resource, ResourceType.DRL);
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());


Regards,
Piotr
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users