"caching" of rules

41 views
Skip to first unread message

Andrew Shapton

unread,
Jun 8, 2015, 9:12:34 AM6/8/15
to open...@googlegroups.com
OK - I have a bunch of rules in XLS files, being utilised by a Java-based program acting as a service exposed by the Dropwizard framework.

Each time I call the service, the XLS files are re-read which takes time.

Is there a way I can load them into memory at the start of the service and use them in each subsequent service call without re-loading.
Ive tried initiating the Decision-type variable in the startup of the service and making it final, so that it can be re-used each time, but each time the service call is called (!) it seems to re-read the XLS files.

Any help would be appreciated..

Andrew

OpenRules Support

unread,
Jun 8, 2015, 1:17:17 PM6/8/15
to open...@googlegroups.com, alsh...@gmail.com
OpenRules loads all rules every time when you create an instance of OpenRulesEngine (or indirectly an instance of Decision using an xls-file). There are many ways to avoid this expensive rules loading. For example, create and remember an instance of OpenRulesEngine once. Then for each service request create and instance of the Decision using the constructor 

Decision decision = new Decision("Decision-name", engine);

This is a very inexpensive call. You also may create one decision. memorize it, and for each request simple call decision.run() preliminary putting new parameters to the decision. 

In real-production environments our customers usually create and memorize an instance of OpenRulesEngine on a server per user session and then share this instance for different requests. You also may deploy an OpenRules project as a web service - see 

Support
Reply all
Reply to author
Forward
0 new messages