On Jan 21, 2010, at 11:29 AM, Luis Fernando Planella Gonzalez wrote:
Ops... I could swear I had seen somewhere that @Asynchronous was one
of those already implemented features from EJB 3.1, just like
@Singleton....
I'll see if there's an area I can help.
Help is always welcome. This one is tricky to describe, so I'm going
to try the Mr. Wizzard approach and list the "ingredients" first. Ok,
so for this functionality, we need:
- a thread pool (java.util.concurrent.Executor) -- can use a
standard impl
- a java.util.concurrent.FutureTask
- a java.util.concurrent.Callable -- we will have to make one of these
The callable will be a class that does the actual execution of the
async method, we'll be constructing one per method call passing in the
method to be invoked, the object itself, and the parameters.
In the main request thread we will not invoke the target method
directly, instead we will:
1. construct a Callable object that contains all the information to
do the invocation
2. construct a FutureTask using the Callable
3. give the FutureTask to the Executor
4. return the FutureTask as the return value
We don't need to plum all this into the container code just yet.
Initially we just need a little class (maybe add it to
org.apache.openejb.util) that wraps all of this up and some test cases
for it. We can worry about the when and where to use it question
later -- it's much tricker and far less isolated.
Hopefully this is enough to get started if you're interested in
hacking on it.
-David
And, do you have an idea about when OpenEJB 3.1.3 will be released?
No date has been set yet, do you have a preference?
-David
Em Quarta-feira 20 Janeiro 2010, às 19:38:52, David Blevins escreveu:
Hi Luis,
This is one area of EJB 3.1 we don't have implemented yet. I just
finished creating a road map of EJB 3.1 features to help the
development along. Here it is for reference:
http://cwiki.apache.org/OPENEJB/ejb-31-roadmap.html
Contribution is welcome as always :)
-David
On Jan 18, 2010, at 1:43 PM, Luis Fernando Planella Gonzalez wrote:
Hi.
I'm trying to create an asynchronous method invocation using the
@Asynchronous annotation.
However, I'm always having the execution in the same thread as the
caller bean.
What could be wrong here? I've tried to put the @Asynchronous in all
combinations: interface only, impl only, both, and no luck.
Here's the code:
*** Client code:
@Stateless
public class ReportExecutionServiceBean extends BaseServiceBean
implements ReportExecutionServiceLocal {
@EJB
private AsyncReportExecutor reportExecutor;
public ReportVO runReport(ReportExecutionParameters
reportParameters) {
reportId = ... //... code omitted
reportExecutor.executeReport(reportId, reportParameters);
return ... ; // code omitted
}
}
*** Async bean interface:
public interface AsyncReportExecutor {
@Asynchronous
Future<Report> executeReport(Long reportId,
ReportExecutionParameters reportParameters);
}
*** Async bean implementation
@Stateless
public class AsyncReportExecutorBean extends BaseServiceBean
implements AsyncReportExecutor {
@Asynchronous
public Future<Report> executeReport(Long reportId,
ReportExecutionParameters reportParameters) {
// ... code omitted
return new AsyncResult<Report>(report);
}
}
--
Luis Fernando Planella Gonzalez