File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Need understanding of @AccessTimeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Need understanding of @AccessTimeout " Watch "Need understanding of @AccessTimeout " New topic

Need understanding of @AccessTimeout

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Source EJB 3.1 spec. Container Managed Concurrency

A concurrent access attempt that is not allowed to proceed due to locking is blocked until it can make forward progress.
Timeouts can be specified via metadata so that a blocked request can be rejected if a lock is not acquired within a certain amount of time. Concurrent Access Timeouts

A concurrent access attempt that can not immediately acquire the appropriate lock is blocked until it can make forward progress.
@AccessTimeout is used to specify the amount of time the access attempt should be blocked before timing out.

Please let me know if my understanding of @AccessTimeout is correct or incorrect:

Suppose value provided in @AccessTimeout is 30 seconds for a particular Singleton Bean method.
If 2 clients try to access the bean method at same time for write operation,then one of the client call will be blocked for the period as specified in @AccessTimeout.
If the first client operation is completed within 20 seconds then second client request can be executed.
If first client operation takes more than 30 seconds ,then second client operation will time-out.

OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2092

Correct and the second client in your last example will receive a ConcurrentAccessTimeoutException (subclass of EJBException) on the time-out.

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Thanks Frits
I agree. Here's the link:
subject: Need understanding of @AccessTimeout
It's not a secret anymore!