Hello Mr. Friedman-Hill,
We are using Jess version 7.0b6 via the jsr 94 rules engine api and experiencing what appears to be a concurrency problem. Here is some context. We assert fairly complex
java objects as facts into a StatelessRuleSession instance. The StatelessRuleSession objects are created by a factory that is thread-safe and we do not pool or resuse the StatelessRuleSession instances. In all cases, we use the StatelessRuleSession objects like so:
StatelessRuleSession ruleSession = RuleSessionFactory.getRuleSession(uri);
try
{
List facts = ...;
ruleSession.executeRules(facts);
}
finally
{
ruleSession.release();
}
The rules are designed to modify the facts. There are two types of facts, say type A and type B, a single list containing instances of A and B objects are passed to the executeRules method of the StatelessRuleSession object. The rules find a fact B that matches fact A and inserts the matching B object into the A object. The hashCode of A and B do not depend on each other. i.e. the hashCode is not modified by inserting an instance of A into B. When we execute our application in single-threaded mode, all the rules fire as expected and our tests pass. However, when our application accepts multiple requests (each in a separate thread) we occasionally experience the following behaviour:
1) rules not firing
2) B objects asserted into the RuleSession contains A objects asserted into a different instance of a RuleSession
We only see this behaviour when multiple requests are being handled by a given Java process in separate threads. We we send the same requests to our application in a serialized manner, we do not see this behaviour.
Does Jess reuse instances of StatelessRuleSession objects or retain state in some manner?
thanks in advance,
Jungho