我想使用 WorkManager 在 WebLogic 10.3 应用服务器上安排一些并行作业。
http://java.sun.com/javaee/5/docs/api/javax/resource/spi/work/WorkManager.html
我发现 Oracle/BEA 文档有点零散且难以理解,并且它没有很好的示例来使用 EJB 3.0 中的 WorkManagers。
具体来说,我想知道:
1) 我需要在我的部署描述符(ejb-jar.xml 和 friend )中放入什么(如果有的话)?
2) 我想使用 @Resource 注释将 WorkManager 注入(inject)我的 EJB 3 session bean。我为资源使用什么“名称”?
3)如何配置WorkManager的线程数等参数。
我的理解是 WebLogic 的底层实现是 CommonJ,但如果可能的话,我更愿意使用非专有的方法。
最佳答案
首先,您将在 Timer and Work Manager API (CommonJ) Programmer’s Guide 中找到 CommonJ 的文档,它是由 BEA Oracle 和 IBM 开发的 Timer 和 Work Manager API 的实现。 .他们提供了一个工作管理器示例,但未在本文档中注入(inject)。
1) What exactly, if anything, do I need to put in my deployment descriptors (ejb-jar.xml and friends)?
根据Work Manager Deployment部分:
Work Managers are defined at the server level via a resource-ref in the appropriate deployment descriptor. This can be web.xml or ejb-jar.xml among others.
The following deployment descriptor fragment demonstrates how to configure a
WorkManager
:... <resource-ref> <res-ref-name>wm/MyWorkManager</res-ref-name> <res-type>commonj.work.WorkManager</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> ...
Note: The recommended prefix for the JNDI namespace for WorkManager objects is java:comp/env/wm.
查看WorkManager javadocs 以获取更多详细信息(例如,“在此版本的规范中忽略了 res-auth 和 res-sharing 范围。然后 EJB 或 servlet 可以根据需要使用 WorkManager。”)。
2) I'd like to use the @Resource annotation to inject the WorkManager into my EJB 3 session bean. What "name" do I use for the resource?
我会说这样的话(未经测试):
@ResourceRef(jndiName="java:comp/env/wm/MyWorkManager",
auth=ResourceRef.Auth.CONTAINER,
type="commonj.work.WorkManager",
name="MyWorkManager")
3) How do I configure the number of threads and other parameters for the WorkManager.
参见
<work-manager>
的描述元素和 Using Work Managers to Optimize Scheduled Work有关工作管理器的详细信息My understanding is that the underlying implementation on WebLogic is CommonJ, but I'd prefer to use a non-proprietary approach if possible.
我没有任何其他建议(而且,只要这个实现遵循标准,我不介意使用它)。
关于concurrency - 如何在 WebLogic 10.3 中配置 WorkManager?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1471081/