[jboss-user] [JBoss Seam] - serializing access to resource
do-not-reply at jboss.com
Thu Feb 7 23:07:33 EST 2008
I need to access an entity bean instance in a serial fashion, so I kindly request for any pattern to implement this.
The use case is similar to managing an account balance, the account must be blocked during modification. I need to block other requests until the resource is available (as if it was a printer). That is why optimistic locking is not suitable.
I don't think synchronizing the SFSB which handles the entity bean is the best way since that would serialize invocation regardless of the entity bean instance been updated, I only want to avoid concurrently modifying the same entity bean instance.
Jboss 4.0 official guide describes the transaction lock behaviour which: anonymous wrote : ensures that only one transaction at a time has access to a given entity bean
But it is not clear to me how this apply in the case, for example, of two entitymanagers loading same entity bean. Does it mean the second one's thread will be locked at that precise moment?
Also I don't quite grasp the behavior of entitymanager.lock(), what happens when another thread tries to lock one entity bean instance already locked? the locking effect is global to different entitymanager instances?
I deeply appreciate any advice
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127665#4127665
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127665
More information about the jboss-user