结合使用带有Future<?>的EJB目的 [英] Using EJB with Future<?> object

查看:71
本文介绍了结合使用带有Future<?>的EJB目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用异步EJB并通过Future对象查询结果?任何人都可以通过完整的示例向我展示.

How I can use async EJB's and asking for result with Future object ? Can anyone show me by a complete example.

推荐答案

在EJB 3.1之前,如果要执行异步处理,则必须使用JMS和MDB,在EJB 3.1中,可以将简单的会话EJB与必须异步调用的方法上的@Asynchronous注释一起使用.

Before EJB 3.1,If you want to execute an asynchronous processing you had to use JMS and a MDB,In EJB 3.1, you can use a simple session EJB with the @Asynchronous annotation on the method which must be called asynchronously.

@Stateless
@Remote(HelloEjbAsynchronousRemote.class)
public class HelloEjbAsynchronous implements HelloEjbAsynchronousRemote {

@Asynchronous
@Override
public Future<String> ejbAsynchronousSayHello(String name){

如果您的方法具有返回值,则您的方法必须返回AsyncResult对象,该对象是Future的实现.

If your method has a return value, your method has to return an AsyncResult object which is an implementation of Future.

return new AsyncResult<String>("Hello "+name);

这篇关于结合使用带有Future&lt;?&gt;的EJB目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆