Hi,

Jay SenSharma

Jay SenSharma

Most of the time we have observed that many WebLogic Developers and Admins face various issues while configuring and looking up the Application Level WorkManager.

WebLogic Server prioritizes work and allocates threads based on an execution model that takes into account administrator-defined parameters and actual run-time performance and throughput.

Work Managers can be configured at the domain level, application level, and module level in one of the following configuration files:

  • config.xml—Work Managers specified in config.xml can be assigned to any application, or application component, in the domain. You can use the Administration Console to define a Work Manager.
  • weblogic-application.xml—Work Managers specified at the application level can be assigned to that application, or any component of that application.
  • weblogic-ejb-jar.xml or weblogic.xml—Work Managers specified at the component-level can be assigned to that component.
  • weblogic.xml—Work Managers specified for a Web Application.

Here is a Simplest sample we are going to develop…to see how to utilize the Application level Work Managers. It means we need NOT to configure any WorkManager using Admin Console…It will be configured through Deployment Descriptor.

Step1). First of all we will develop the “index.jsp” page to see how to lookup the “commonj.work.WorkManager” and the TimerManager which we are going to configure …

<%@ page import="javax.naming.InitialContext,commonj.timers.TimerManager" %>
<%
System.out.println("nnt ---------------1-------------");
TimerManager timerManager = null;
try {
InitialContext initContext = new InitialContext();
timerManager = (TimerManager) initContext.lookup("java:comp/env/timer/TestTimer");
System.out.println("nnt I am able to Lookup: "+timerManager);
out.println("<b><font color=GREEN>"timer/TestTimer" Created Using DD</font> I am able to Lookup:</b>"+timerManager);
}
catch (Throwable anException)
{
throw new RuntimeException(anException);
}
System.out.println("nnt ---------------2-------------");
try {
InitialContext initContext2 = new InitialContext();
commonj.work.WorkManager workManager = (commonj.work.WorkManager)initContext2.lookup("java:comp/env/wm/WorkManagerA");
System.out.println("nnt I am able to Lookup: commonj.work.WorkManager workManager = "+workManager);
out.println("<BR><BR><BR><b><font color=red>Application Level Work Manager.</font>  I am able to Lookup:</b> "+workManager);
}
catch (Throwable anException)
{
System.out.println("nnt Exception Thrown: "+anException);
throw new RuntimeException(anException);
}
System.out.println("nnt ---------------3-------------");
%>

Step2). Now we will develope the “web.xml” here we will provide the reference to the WorkManager and the TimerManager resource -ref

<web-app xmlns="http://java.sun.com/xml/ns/j2ee">
   <resource-ref>
        <res-ref-name>timer/TestTimer</res-ref-name>
        <res-type>commonj.timers.TimerManager</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
  </resource-ref>

  <resource-ref>
        <res-ref-name>wm/WorkManagerA</res-ref-name>
        <res-type>commonj.work.WorkManager</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>
</web-app>
Step 3). Now we need to define the <work-manager>  tag in “weblogic.xml” file…
<?xml version="1.0" encoding="ISO-8859-1"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
    <work-manager>
       <name>WorkManagerA</name>
       <max-threads-constraint>
          <name>MyMaxThreadCount_2</name>
          <count>2</count>
       </max-threads-constraint>
    </work-manager>
    <wl-dispatch-policy>WorkManagerA</wl-dispatch-policy>
</weblogic-web-app>
Step 4). Now we need to Deploy this Application in WebLogic Server then We will find …Now Login to Admin Console here in “Home—>Deployments—>WorkManagerDemoApp—>Configuration(Tab)—>WorkLoad(Tab)” we can see that WorkManagerA is configured as soon as the deployment was Successful…

.
.
Thanks
Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.