Tag: WorkManager

WorkManager At WebApplication Level

Hi,

Jay SenSharma

Jay SenSharma

If you want to Assign a Global Work Manager (A Work Manager which is created through AdminConsole).. And if you want more than 1-Thread should not be allocated by the WebLogic to process request for your WebApplication…then you can do the Following:

Provide the Capacity-Constraint to 1

Step1). Configure a WorkManager from Admin Console.

with the following Configuration: in your “config.xml”

<self-tuning>
<context-request-class>
<name>ContextReqClass-0</name>
<target>AdminServer</target>
</context-request-class>

<min-threads-constraint>
<name>MyMaxConstraint</name>
<target>AdminServer</target>
<count>1</count>
</min-threads-constraint>

<capacity>
<name>CapacityConstraint-0</name>
<target>AdminServer</target>
<count>1</count>
</capacity>

<work-manager>
<name>myConsoleWorkManager</name>
<target>AdminServer</target>
<context-request-class>ContextReqClass-0</context-request-class>
<min-threads-constraint>MyMaxConstraint</min-threads-constraint>
<capacity>CapacityConstraint-0</capacity>
</work-manager>

</self-tuning>
Note: After configuring the above workManager we need to restart the Server…
Step2). Write a Simple WebApplication with the following kind of JSP Page:
<%@ page import="java.util.*" %>
<%!
static int counter=0;
%>
<%
session.setAttribute("counter","Counter-"+counter);
counter++;
for(int id=0;id<60;id++)
{
System.out.println(id+"tRequest Is Being Processsed for :"+(String)session.getAttribute("counter"));
try{
Thread.sleep(1000);
}
catch(Exception e)
{
e.printStackTrace();
}
}
out.println("<h2>Request Processing Completed");
%>
Step3). Now provide the “weblogic.xml” bu providing the Work-Manager name in wl-dispatch-policy annotation:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
<wl-dispatch-policy>myConsoleWorkManager</wl-dispatch-policy>
</weblogic-web-app>
Step4). Now deploy the Application and And
you can check it from admin console as well..

AdminConsole–> Home–>Deployment Summary–> (click on your WebApp)–>Monitoring (Tab)—> WorkLoad (Sub-Tab)

Hit your WebApplication and then See …in admin Console…How many request is being processed…

When you send the Concurrent Second request to the WebApplication you will get 503-Service Not Available Error By the WebLogic Server…Because of the Constraint Capicity=1 …weblogic will process only 1 Concurrent request for your WebApplication.

.

.

Thanks

Jay SenSharma



Application Level WorkManager & TimerManager Lookup

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


Copyright © 2010-2012 Middleware Magic. All rights reserved. |