[rules-users] how do RuleBase.lock()/unlock() functions work?

Marina ppine7 at yahoo.com
Tue Aug 26 04:24:20 EDT 2008


Sorry to bring it up again - just was wondering if anybody knows the answer to my questions below, or maybe it is already somewhere in the documentation?

Thanks!
Marina



----- Original Message ----
From: Marina <ppine7 at yahoo.com>
To: Rules Users List <rules-users at lists.jboss.org>
Sent: Friday, August 22, 2008 3:42:01 PM
Subject: [rules-users] how do RuleBase.lock()/unlock() functions work?

Hello!

I am researching how to do thread safe update of packages/rules in a rulebase. I noticed that there are lock() and unlock() methods on the RuleBase object, but could not find much documentation on how they could be used.
I am trying to implement the following scenario and was wondering if someone could verify that I am using the lock functionality correctly in this case:

Thread1:
1. rulebase.getStatelessSession()
1.1 rulebase.lock()
1.2 rulebase.removeRule(rule1)
1.3 rulebase.removePackage(somePackage)
1.4 rulebase.addPackage(someCompiledNewPackage)
1.5 rulebase.unlock()

Thread2
2. rulebase.getStatelessSession()

Threads 1 and 2 use the same rulebase object.
Quesion 1: What does it mean having the rulebase be locked in Thread1? Does it mean, that if Thread2 is trying to get the session , say, between steps1.2 and 1.3 of the Thread1 , then it will wait until Thread1 released the lock on the rulebase?

If that's true, that's exactly what I need.

Question 2: I also see methods rulebase.getAdditionsSinceLock() and getRemovalsSinceLock(). Who will see anything when calling these functions - Thread1 after operation 1.5? before 1.5? 
Or Thread2? But, which lock would it mean to Thread2? - it woudl probably not even be aware of any locks being place by other threads??

Thanks!
Marina
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list