Hi all,
I'm seeing consistency issues when trying to refresh rules manually. I am
seeing issues with sessions getting different results while I call this
function in a loop. Is there a more proper way of migrating the sessions over
to a rules base that has updated rules?
/**
* Function to compile the drools rules. It reads the rules from the data
access object
* @throws APIException
*/
public static void refreshRules() throws APIException {
if(null == DAO) return;
try {
DAO.getSqlMapClient().flushDataCache();
RULES_BASE.lock();
Package[] packages = RULES_BASE.getPackages();
for(int i = 0; i < packages.length; ++i) {
RULES_BASE.removePackage(packages[i].getName());
}
Properties properties = new Properties();
properties.setProperty( "drools.dialect.java.compiler",
"JANINO" );
PackageBuilderConfiguration cfg = new
PackageBuilderConfiguration( properties );
PackageBuilder builder = new PackageBuilder(cfg);
Collection<DroolsVO> rulesCollection = DAO.getRules();
for(DroolsVO rule : rulesCollection) {
Reader source = new StringReader(rule.getRules());
builder.addPackageFromDrl(source);
}
Package pkg = builder.getPackage();
if(null != pkg) {
RULES_BASE.addPackage(pkg);
}
} catch(... e) {
throw APIExceptionFactory.generateException(e);
} finally {
RULES_BASE.unlock();
}
}
Show replies by date