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

Marina ppine7 at yahoo.com
Tue Aug 26 10:40:45 EDT 2008


Thanks, Mark
Actually, the lock you are describing is a low-level lock on the single add/remove operations. I was more interested in locking a set of operations together.

I guess the only way to do it is to use a normal Java lock outside of the rule engine.

Thanks,
Marina



----- Original Message ----
From: Mark Proctor <mproctor at codehaus.org>
To: Rules Users List <rules-users at lists.jboss.org>
Sent: Tuesday, August 26, 2008 8:36:29 AM
Subject: Re: [rules-users] how do RuleBase.lock()/unlock() functions work?

you should not need to call .lock() to add or remove packages, the lock 
is applied automatically when you cann add/remove on the rulebase. 
Likewise ignrore  additions/removeas since lock, it's really not 
relevant to users.
The Lock is a JDK Lock object, so see that for understanding on how a 
lock work.s

Mark
Marina wrote:
> 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
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>  

_______________________________________________
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