Bean implementation programming model for EJB asynchronous methods
We can configure asynchronous methods on session beans. However, as documented in the EJB 3.1 specification, asynchronous methods must not be configured on entity beans, or message-driven beans.
Implementations of asynchronous methods must have a return type of void or of type, java.util.concurrent.Future <V>. No other return types are supported on the implementation. As documented in the EJB 3.1 specification, the bean implementation method must have the same return type as the interface specification. For more information, read about the client programming model for EJB asynchronous methods.
Nested asynchronous calls are supported; an asynchronous method call can be made from within an asynchronous method.
When nesting asynchronous method calls, take into consideration the work manager settings to allow enough resources (maximum number of threads and work request queue size). For more information, read about the work manager for asynchronous methods.gotcha
Bean implementers must consider how long their asynchronous methods take to run because each request is invoked on a different thread. Another important consideration is the number of asynchronous method requests that an application is likely to start in parallel. These issues are important because the number of threads that are allocated to run asynchronous methods in the server process is a limited resource. Also, the buffer space that is allocated in the server process to queue asynchronous method requests, during times that all the allocated threads are busy, is a limited resource. For more information, read about the client programming model for EJB asynchronous methods.
Finally, bean implementers must follow the EJB 3.1 specification restrictions regarding the transaction attribute settings allowed on EJB asynchronous methods. For more information, read about the EJB container work manager for asynchronous methods.
Related concepts
EJB 3.1 asynchronous methods Client programming model for EJB asynchronous methods EJB container work manager for asynchronous methods
Related tasks
Configure EJB 3.1 session bean methods to be asynchronous