使用超时进行EJB调用 [英] Make EJB call with timeout

查看:183
本文介绍了使用超时进行EJB调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个EJB A ,它调用EJB B 。用户界面不应等待超过30秒的响应。如果缺少某些数据,则应返回部分响应。

I have an EJB A that invokes EJB B. The UI should not wait for more than 30 seconds for a response. If some data is missing, it should return a partial response.

如何在EJB B上定义超时(时间限制为30秒)

我可以将EJB B 定义为异步返回 Future ,然后执行 Future.get(30,TimeUnit.SECONDS)
但它是最好的解决方案吗?

I can define EJB B as Asynchronous that returns Future, and then do Future.get(30, TimeUnit.SECONDS). But is it the best solution?

谢谢

P.S。我使用glassfish 3.1

P.S. I use glassfish 3.1

推荐答案

要为适用于其所有方法的bean配置超时,您必须配置属性<$ glassfish-ejb-jar.xml中的c $ c> cmt-timeout-in-seconds 。

To configure timeout for a bean which applies to all its methods, you have to configure the attribute cmt-timeout-in-seconds in glassfish-ejb-jar.xml.

此超时值由所有人使用启动新事务的bean的方法,当它们加入其他正在进行的事务时不适用。

This timeout value is used by all the methods of the bean that initiates a new transaction, not applicable when they join other ongoing transaction.

也可以参考这个链接了解有关超时的更多详情。

Also can refer this link for further details on timeout.

这篇关于使用超时进行EJB调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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