How Does a RuleSession Handle Concurrency and Synchronization?
Method calls on an Oracle Business Rules RuleSession object are thread-safe such that calls by multiple threads do not cause exceptions at the RuleSession level. However, there are no exclusivity or transactional guarantees on the execution of methods. The lowest-level run method in the Rules Engine is synchronized, so two threads with a shared RuleSession cannot both simultaneously execute run. One call to run must wait for the other to finish. RL Functions are not synchronized by default. Like Java methods, RL functions can execute concurrently and it is the programmer’s responsibility to use synchronized blocks to protect access to shared data (for instance, a HashMap containing results data). Any set of actions that a user wishes to be executed as in a transaction-like form must synchronize around the shared object. Users should not synchronize around a RuleSession object because exceptions thrown when calling RuleSession methods may require the RuleSession object to be discarded.