Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you configure WorkManagers in WebLogic 10.3?

I would like to use a WorkManager to schedule some parallel jobs on a WebLogic 10.3 app server.

http://java.sun.com/javaee/5/docs/api/javax/resource/spi/work/WorkManager.html

I'm finding the Oracle/BEA documentation a bit fragmented and hard to follow and it does not have good examples for using WorkManagers from EJB 3.0.

Specifically, I'd like to know:

1) What exactly, if anything, do I need to put in my deployment descriptors (ejb-jar.xml and friends)?

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?

3) How do I configure the number of threads and other parameters for the WorkManager.

My understanding is that the underlying implementation on WebLogic is CommonJ, but I'd prefer to use a non-proprietary approach if possible.

like image 493
hallidave Avatar asked Sep 24 '09 11:09

hallidave


People also ask

What is the use of work manager in WebLogic?

The Default Work ManagerTo handle thread management and perform self-tuning, WebLogic Server implements a default Work Manager. This Work Manager is used by an application when no other Work Managers are specified in the application's deployment descriptors.

Can we deploy ear file in WebLogic?

Start WebLogic Server. Specify the WebLogic Server user name and password. In the WebLogic Server console, follow the instructions to deploy the maximo. ear file.


1 Answers

First, you'll find the documentation of CommonJ, an implementation of the Timer and Work Manager API developed by BEA Oracle and IBM, in Timer and Work Manager API (CommonJ) Programmer’s Guide. They provide a Work Manager Example but it's not injected in this document.

1) What exactly, if anything, do I need to put in my deployment descriptors (ejb-jar.xml and friends)?

According to the Work Manager Deployment section:

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.

Check the WorkManager javadocs for more details (e.g. "The res-auth and res-sharing scopes are ignored in this version of the specification. The EJB or servlet can then use the WorkManager as it needs to.").

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?

I'd say something like this (not tested):

@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.

See the description of the <work-manager> element and Using Work Managers to Optimize Scheduled Work for detailed information on Work Managers

My understanding is that the underlying implementation on WebLogic is CommonJ, but I'd prefer to use a non-proprietary approach if possible.

I don't have any other suggestion (and, as long as this implementation follows the standards, I wouldn't mind using it).

like image 169
Pascal Thivent Avatar answered Oct 14 '22 13:10

Pascal Thivent