Work Manager Configuration in Weblogic

Work Managers  allow to configure a set of guidelines that Weblogic Server uses to prioritize and organize the execution of tasks in an optimized way. Work Manager can be broadly categorized into two categories 1) Global Work Manager and 2) Application Scoped Work Manager.

Using Global Work Manager, rules can be configured at the domain level and these rules can then be applied to any application or any application component deployed in the weblogic server. Work Managers at domain level can be configured either by using Weblogic Administration Console or by modifying config.xml file. Focus of this post is on application scoped work managers as explained below. To find out how to create global work manager, you may want to look here.

Using Application Scoped Work Manager, rules are configured specific to an application. This means that if two applications A and B are deployed in weblogic server, work manager configured for application A can not be used by application B (as simple as that).

Configuring work manager is a two step process – first create work manager and then assign it to a component. We will be discussing two ways of configuring application scoped work managers – one is to create work managers at application level and using them for a component/module (e.g. EJB), second is to create work managers at module level. Of course there is an advantage with the first approach as few standard work managers can be created once for an application and can be used across all the modules in the application. Let’s see how to use work mangers using both the approaches.

Using Work Manager at Application Level


To create work manager at application level, weblogic-application.xml file needs to be modified as below:

Now to assign work manager to a specific EJB, weblogic-ejb-jar.xml file needs to be modified as below:

To check that work manager has been been configured successfully, open weblogic console and go to Deployments -> Select your application -> Monitoring -> Workload. “testWorkmanager”, “testMaxThreadConstraint” and “testMinThreadConstraint” should be listed under Work Manager, Min Threads Constraint and Max Threads Constraint tables respectively.

Thus, by following above steps application scoped work manager can be created. These work manager can then be assigned to any component/module in the application.

Using Work Manager at Module Level


To create work manager at module level, weblogic-ejb-jar.xml file needs to be modified as below:

Now to assign work manager to a specific EJB, weblogic-ejb-jar.xml file needs to be updated as below:

Thus, to configure work manager at module level, only one file i.e. weblogic-ejb-jar.xml needs to be modified as explained above. To ensure that work manager has been configured successfully, open the weblogic console, go to Deployments -> expand your application -> select the EJB to which work manager has been assigned -> Monitoring -> Workload. “testWorkmanager”, “testMaxThreadConstraint” and “testMinThreadConstraint” should be listed under Work Manager, Min Threads Constraint and Max Threads Constraint tables respectively.

Using CommonJ to Configure Work Manager


Under this heading we would be discussing how CommonJ can be used to programatically schedule the task.  First we need to create work manager, that can be done by using either of the two methods explained above. Let’s take first approach here, so to create work manager, first we need to modify weblogic-application.xml as below:

Now, to assign the work manager created above to a specific EJB, we would be modifying ejb-jar.xml as below. Note that instead of modifying weblogic-ejb-jar.xml as explained in the first approach, we are modifying ejb-jar.xml.

Now we need to reference work manager in EJB for scheduling the tasks as below:

Note: To get work manager reference using JNDI, below code can be used:

Thus, using work managers certain rules can be defined for an application for it to work in an optimized way. For further understanding of work manager and various rules & constraints, refer this.

Hope that you find the information presented here useful. Please feel free to leave your footprints in the comment section below for any queries, feedback or suggestions.

  1. Hi,
    thanks for wonderful information, well I tried using global work manager my test case is as below
    I have to domains ejbdomain and clientdomain
    I defined global workmanager(fairshare 50) for ejbdomain to accept only one request min=1 max=1 cap=0/1
    my each ejb when called takes 15sec to reply back response so my client web applicaiton calls 4 request in 1 sec each.
    ideally I should get error after 2nd request but I found that
    all request goes to ejbdomain and gives response. I don’t know why. when i make ejb to reply more than 17 sec i get transaction timeout exp. after 17 sec which is not I was checking for.
    I would like that ejbdomain should only take one req. and throw back other request to clientdomain.
    can you please able to explain why its taking all reqest?
    I am using weblogic 10.0.2

  2. Thanks for the very informative article. I have one question: Is it possible to programatically invoke a workManager (like in the “Using CommonJ to Configure Work Manager” part of your article) without creating an entry in ejb-jar.xml? Can it be done by creating entries in weblogic-ejb-jar.xml and/or by @Resource annotation alone?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">