[rules-users] Executing Rules in Sequential Mode
Jin, Ming
Ming.Jin at travelocity.com
Wed Aug 15 11:32:40 EDT 2007
My rules engine test showed virtually no difference between Rete and
Sequential execution modes: 3.44s for Rete while 3.50s for Sequential.
Those are the average timing from several runs, each with 1,000 rule
execution calls. Since I do not have a controlled environment, the
difference seems insignificant. (The other rules engine I tested showed
huge improvement for the same rule set comparing Sequential with Rete).
The following code segments show how RuleBaseConfiguration is set and
the rule execution. Traced into the code a little bit, and did see the
sequential flag set and the order() method was called.
Please advise if this is the proper way to set sequential. Otherwise, I
would just conclude that sequential mode has no effect for this
particular rule set under Drools.
I would like to add that even without sequential, Drools performance was
fantastic.
Thanks,
-Ming
/**
* Creates a RuleBase instance with the given package object and the
sequential execution flag.
* @param pkg
* @param sequential true for sequential mode, false defaults to Rete
* @return the created RuleBase with the given package and execution
mode.
* @throws Exception
*/
private static RuleBase createRuleBase(Package pkg, boolean
sequential) throws Exception {
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setSequential(sequential);
RuleBase rb = RuleBaseFactory.newRuleBase(conf);
rb.addPackage(pkg);
return rb;
}
// code segments for rule execution
StatelessSession session = rulebase.newStatelessSession();
StatelessSessionResult result =
session.executeWithResults(list);
More information about the rules-users
mailing list