WebLogic Server uses a thread pool to execute various types of work and prioritizes the execution of work based on the rules and the run-time metrics you define in the Work Manager.
In previous versions of WebLogic Server, processing was performed in multiple execute queues. Different classes of work were executed in different queues, based on priority and ordering requirements, and to avoid deadlocks. In addition to the default execute queue,
weblogic.kernel.default, there were pre-configured queues dedicated to internal administrative traffic, such as
You could control thread usage by altering the number of threads in the default queue, or configure custom execute queues to ensure that particular applications had access to a fixed number of execute threads, regardless of overall system load.
Now WebLogic Server uses a single thread pool, in which all types of work are executed. WebLogic Server prioritizes work based on rules you define, and run-time metrics, including the actual time it takes to execute a request and the rate at which requests are entering and leaving the pool.
The common thread pool changes its size automatically to maximize throughput. The queue monitors throughput over time and based on history, determines whether to adjust the thread count. For example, if historical throughput statistics indicate that a higher thread count increased throughput, WebLogic increases the thread count. Similarly, if statistics indicate that fewer threads did not reduce throughput, WebLogic decreases the thread count. This new strategy makes it easier for administrators to allocate processing resources and manage performance, avoiding the effort and complexity involved in configuring, monitoring, and tuning custom executes queues.
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.
Administrators can configure a set of scheduling guidelines and associate them with one or more applications, or with particular application components. For example, you can associate one set of scheduling guidelines for one application, and another set of guidelines for other applications. At run time, WebLogic Server uses these guidelines to assign pending work and enqueued requests to execution threads.
Work requests from all Work Managers are executed by a single thread pool; separate thread pools are not created for each Work Manager.
To manage work in your applications, you define one or more of the following Work Manager components:
Fair Share Request Class
Response Time Request Class
Min Threads Constraint
Max Threads Constraint
Context Request Class
You can use any of these Work Manager components to control the performance of your application by referencing the name of the component in the application deployment descriptor. In addition, you may define a Work Manager that encapsulates all of the above components (except Context Request Class; see Example 2-3) and reference the name of the Work Manager in your application's deployment descriptor. You can define multiple Work Managers—the appropriate number depends on how many distinct demand profiles exist across the applications you host on WebLogic Server.
You can configure Work Managers at the domain level, application level, and module level in one of the following configuration files, or by using the WebLogic Server Administration Console:
config.xml—Work Managers specified in
config.xml can be assigned to any application, or application component, in the domain.
weblogic-application.xml—Work Managers specified at the application level can be assigned to that application, or any component of that application.
weblogic.xml—Work Managers specified at the component level can be assigned to that component.
weblogic.xml—Work Managers specified for a Web application.
Example 2-1 is an example of a Work Manager definition.
Example 2-1 Work Manager Stanza
<work-manager> <name>highpriority_workmanager</name> <fair-share-request-class> <name>high_priority</name> <fair-share>100</fair-share> </fair-share-request-class> <min-threads-constraint> <name>MinThreadsCountFive</name> <count>5</count> </min-threads-constraint> </work-manager>
Example 2-2 Referencing the Work Manager in a Web Application
To assign the Work Manager to control the dispatch policy of a particular servlet, add the following code to the Web application's
<servlet> ... <init-param> <param-name>wl-dispatch-policy</param-name> <param-value>highpriority_workmanager</param-value> </init-param> ... </servlet>
The components you can define and use in a Work Manager are described in following sections:
A request class expresses a scheduling guideline that WebLogic Server uses to allocate threads to requests. Request classes help ensure that high priority work is scheduled before less important work, even if the high priority work is submitted after the lower priority work. WebLogic Server takes into account how long it takes for requests to each module to complete.
Request classes define a best effort. They do not guarantee that the configured ratio will be maintained consistently. The observed ratio may vary due to several factors during a period of sufficient demand, such as:
The mixture of requests from different request classes in the queue at any particular time. For example, more requests than the configured ratio may be processed for a lower priority request class if there are not enough requests from a higher priority request class in the Work Manager queue.
Because the ratio is specified in terms of thread-usage time, a larger number of shorter requests could be processed in the same amount of thread-usage time as a smaller number of time-consuming requests.
There are multiple types of request classes, each of which expresses a scheduling guideline in different terms. A Work Manager may specify only one request class.
fair-share-request-class—Specifies the average thread-use time required to process requests. The default fair share value is 50.
For example, assume that WebLogic Server is running two modules. The Work Manager for
ModuleA specifies a
fair-share-request-class of 80 and the Work Manager for
ModuleB specifies a
fair-share-request-class of 20.
During a period of sufficient demand, with a steady stream of requests for each module such that the number requests exceed the number of threads, WebLogic Server will allocate 80% and 20% of the thread-usage time to
The value of a fair share request class is specified as a relative value, not a percentage. Therefore, in the above example, if the request classes were defined as 400 and 100, they would still have the same relative values.
response-time-request-class—Specifies a response time goal in milliseconds. Response time goals are not applied to individual requests. Instead, WebLogic Server computes a tolerable waiting time for requests with that class by subtracting the observed average thread use time from the response time goal, and schedules requests so that the average wait for requests with the class is proportional to its tolerable waiting time.
For example, given that ModuleA and ModuleB in the previous example, have response time goals of 2000 ms and 5000 ms, respectively, and the actual thread use time for an individual request is less than its response time goal. During a period of sufficient demand, with a steady stream of requests for each module such that the number of requests exceed the number of threads, and no "think time" delays between response and request, WebLogic Server will schedule requests for
ModuleB to keep the average response time in the ratio 2:5. The actual average response times for
ModuleB might be higher or lower than the response time goals, but will be a common fraction or multiple of the stated goal. For example, if the average response time for
ModuleA requests is 1,000 ms., the average response time for
ModuleB requests is 2,500 ms.
The previous sections described request classes based on fair share and response time by relating the scheduling to other work using the same request class. A mix of fair share and response time request classes is scheduled with a marked bias in favor of response time scheduling.
context-request-class—Assigns request classes to requests based on context information, such as the current user or the current user's group.
For example, the
context-request-class in Example 2-3 assigns a request class to requests based on the value of the request's
low_fairshare request classes referenced by the
context_workmanager in Example 2-3 could be defined in the
config.xml as follows:
<self-tuning> ... <fair-share-request-class> <name>high_fairshare</name> <target>myserver</target> <fair-share>75</fair-share> </fair-share-request-class> <fair-share-request-class> <name>low_fairshare</name> <target>myserver</target> <fair-share>25</fair-share> </fair-share-request-class> ... </self-tuning>
If a Web application's Work Manager references a context request class, the first user call will go through the default request class; subsequent calls in same session will go through the user-defined request class.
When using context request classes, set session timeout values to prevent sessions from expiring while requests wait in the Work Manager queue.
Example 2-3 Context Request Class
<work-manager> <name>context_workmanager</name> <context-request-class> <name>test_context</name> <context-case> <user-name>system</user-name> <request-class-name>high_fairshare</request-class-name> </context-case> <context-case> <group-name>everyone</group-name> <request-class-name>low_fairshare</request-class-name> </context-case> </context-request-class> </work-manager>
A constraint defines minimum and maximum numbers of threads allocated to execute requests and the total number of requests that can be queued or executing before WebLogic Server begins rejecting requests.
You can define the following types of constraints:
max-threads-constraint—Limits the number of concurrent threads executing requests from the constrained work set. The default is unlimited. For example, consider a constraint defined with maximum threads of 10 and shared by 3 entry points. The scheduling logic ensures that not more than 10 threads are executing requests from the three entry points combined.
You can define a
max-threads-constraint in terms of a the availability of the resource that requests depend upon, such as a connection pool.
max-threads-constraint might, but does not necessarily, prevent a request class from taking its fair share of threads or meeting its response time goal. Once the constraint is reached the server does not schedule requests of this type until the number of concurrent executions falls below the limit. The server then schedules work based on the fair share or response time goal.
min-threads-constraint—Guarantees the number of threads the server will allocate to affected requests to avoid deadlocks. The default is zero. A
min-threads-constraint value of one is useful, for example, for a replication update request, which is called synchronously from a peer.
min-threads-constraint might not necessarily increase a fair share. This type of constraint has an effect primarily when the server instance is close to a deadlock condition. In that case, the constraint will cause WebLogic Server to schedule a request even if requests in the service class have gotten more than its fair share recently.
capacity—Causes the server to reject requests only when it has reached its capacity. The default is -1. Note that the capacity includes all requests, queued or executing, from the constrained work set. Work is rejected either when an individual capacity threshold is exceeded or if the global capacity is exceeded. This constraint is independent of the global queue threshold.
Note that the
capacity constraint is not enforced if the request is made by a user belonging to the WebLogic Server Administrators group.
In response to stuck threads, you can define a Stuck Thread Work Manager component that can shut down the Work Manager, move the application into admin mode, or mark the server instance as failed.
For example, the Work Manager defined in Example 2-4 shuts down the Work Manager when two threads are stuck for longer than 30 seconds.
Example 2-4 Stuck-Thread Work Manager
<work-manager> <name>stuckthread_workmanager</name> <work-manager-shutdown-trigger> <max-stuck-thread-time>30</max-stuck-thread-time> <stuck-thread-count>2</stuck-thread-count> </work-manager-shutdown-trigger> </work-manager>
WebLogic Server maintains three groups of threads for the self-tuning thread pool:
Running threads: threads that are currently executing work requests submitted to Work Managers
Idle threads: threads that are idly waiting for a work request
Idle threads include threads that have completed their previous work requests and are waiting for new requests, as well as threads that are created by the self-tuning thread pool based on usage statistics in order to anticipate future workload.
Standby threads: threads that are not currently processing or waiting for work requests
Standby threads do not count toward the self-tuning thread pool thread count. When the self-tuning thread pool decides to decrease the thread count based on usage statistics, threads are moved from the group of idle threads into the group of standby threads. Conversely, when the self-tuning thread pool decides to increase the thread count, it first tries to find threads in the standby thread group to move to the idle thread group. The self-tuning thread pool only creates new threads if there are not enough threads in the standby group.
Threads are shut down when the number of standby threads reaches an internal maximum limit of 256. Ideally, a number of standby threads are ready if WebLogic Server needs to increase the self-tuning thread pool count occurs so that the WebLogic Server instance can avoid creating new threads at a time when workload is high. Standby threads can also be created and used to satisfy minimum threads constraints. See Constraints.
By default, the self-tuning thread pool size limit is 400. This limit includes all running and idle threads, but does not include any standby threads. You can configure the limit using the
SelfTuningThreadPoolSizeMax attribute in the
KernelMBean. You may choose a higher size limit if your system can support additional workload even when the self-tuning thread pool has reached its upper thread count limit. Contrarily, you may choose to lower the limit if your system resources, such as CPU, become overloaded at a lower thread count. However, if lowering the
SelfTuningThreadPoolSizeMax limit, note that if the value is set too low, the self-tuning thread pool may not be allowed to create enough threads to handle the system workload. This could result in a backlog of pending work requests on some Work Managers.
Minimum threads constraints can affect the number of threads that are executing work requests for Work Managers, especially if the WebLogic Server instance is under heavy load.
The self-tuning thread pool does not consider the
SelfTuningThreadPoolSizeMax attribute when creating a new standby thread to process incoming work requests for a Work Manager to satisfy its allocated minimum threads constraint. This is due to the importance of allocating threads for processing work requests for Work Managers with minimum threads constraints, which are designed to be used to avoid server-to-server deadlocks.
As a result, the maximum possible number of threads maintained by the self-tuning thread pool is the sum of the configured
SelfTuningThreadPoolSizeMax attribute value and the sum of the values for all minimum threads constraints configured in the WebLogic Server instance, assuming a worst-case scenario where the configured number of threads are allocated to all configured minimum threads constraints.
To clean up stray ThreadLocal use by applications and third-party libraries, configure the
eagerThreadLocalCleanup attribute in the
eagerThreadLocalCleanup attribute specifies whether to clean up all ThreadLocal storage from self-tuning thread pools after they have finished processing each work request.
By default, the
eagerThreadLocalCleanup attribute is set to false, in which the self-tuning thread pool only cleans up ThreadLocal storage when a thread returns to a standby pool and after an application is undeployed.
eagerThreadLocalCleanup attribute to true ensures that all thread pool threads have no leftover ThreadLocal values from previous requests when running work for a new request. However, overhead occurs from cleaning up ThreadLocal storage after each work request and then reestablishing ThreadLocal values for each new request. Since some applications cache objects that are expensive to create in the ThreadLocal storage, cleaning up ThreadLocal values after each request may negatively impact performance on those applications.
Essentially, there are three types of Work Managers, each one characterized by its scope and how it is defined and used.
To 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.
In many situations, the default Work Manager may be sufficient for most application requirements. WebLogic Server thread-handling algorithms assign each application its own fair share by default. Applications are given equal priority for threads and are prevented from monopolizing them.
You can override the behavior of the default Work Manager by creating and configuring a global Work Manager called
default. This allows you to control the default thread-handling behavior of WebLogic Server.
When you override the default Work Manager, all instances are overridden.
Use the following guidelines to determine when you might want to use Work Managers to customize thread management:
To use Work Manager, it is mandatory to meet one of the guidelines.
The default fair share (50) is not sufficient.
This usually occurs in situations where one application needs to be given a higher priority over another.
A response time goal is required.
A minimum thread constraint needs to be specified to avoid server deadlock
You can create global Work Managers that are available to all applications and modules deployed on a server, in the WebLogic Server Administration Console and in
An application uses a globally-defined Work Manager as a template. Each application creates its own instance which handles the work associated with that application and separates that work from other applications. This separation is used to handle traffic directed to two applications which are using the same dispatch policy. Handling each application's work separately, allows an application to be shut down without affecting the thread management of another application. Although each application implements its own Work Manager instance, the underlying components are shared.
In addition to globally-scoped Work Managers, you can also create Work Managers that are available only to a specific application or module. You can define application-scoped Work Managers in the WebLogic Server Administration Console and in the following descriptors:
If you do not explicitly assign a Work Manager to an application, it uses the default Work Manager.
A method is assigned to a Work Manager, using the <dispatch-policy> element in the deployment descriptor. The <dispatch-policy> can also identify a custom execute queue, for backward compatibility. For an example, see Example 2-2.
Work Managers, Request Classes, and Constraints require a definition and a mapping.
A definition. You may define Work Managers, Request Classes, or Constraints globally in the domain's configuration using the WebLogic Server Administration Console, (see Environments > Work Managers in the WebLogic Server Administration Console) or you may define them in one of the deployment descriptors listed previously. In either case, you assign a name to each.
A mapping. In your deployment descriptors you reference one of the Work Managers, Request Classes, or Constraints by its name.
weblogic-ejb-jar.xml—The value of the existing
dispatch-policy tag under
weblogic-enterprise-bean can be a named
dispatch-policy. For backwards compatibility, it can also name an ExecuteQueue. In addition, Oracle allows
min-threads, to specify named (or unnamed with a numeric value for constraints) policy and constraints for a list of methods, analogously to the present
Examine examples for defining Work Managers in various types of deployment descriptors.
For additional and detailed reference, see the schema for these deployment descriptors:
weblogic.xml schema: See weblogic.xml Deployment Descriptor Elements in Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server.
Example 2-5 weblogic-ejb-jar.xml With Work Manager Entries
<weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.6/weblogic-ejb-jar.xsd"> <weblogic-enterprise-bean> <ejb-name>WorkEJB</ejb-name> <jndi-name>core_work_ejb_workbean_WorkEJB</jndi-name> <dispatch-policy>weblogic.kernel.System</dispatch-policy> </weblogic-enterprise-bean> <weblogic-enterprise-bean> <ejb-name>NonSystemWorkEJB</ejb-name> <jndi-name>core_work_ejb_workbean_NonSystemWorkEJB</jndi-name> <dispatch-policy>workbean_workmanager</dispatch-policy> </weblogic-enterprise-bean> <weblogic-enterprise-bean> <ejb-name>MinThreadsWorkEJB</ejb-name> <jndi-name>core_work_ejb_workbean_MinThreadsWorkEJB</jndi-name> <dispatch-policy>MinThreadsCountFive</dispatch-policy> </weblogic-enterprise-bean> <work-manager> <name>workbean_workmanager</name> </work-manager> <work-manager> <name>stuckthread_workmanager</name> <work-manager-shutdown-trigger> <max-stuck-thread-time>30</max-stuck-thread-time> <stuck-thread-count>2</stuck-thread-count> </work-manager-shutdown-trigger> </work-manager> <work-manager> <name>minthreads_workmanager</name> <min-threads-constraint> <name>MinThreadsCountFive</name> <count>5</count> </min-threads-constraint> </work-manager> <work-manager> <name>lowpriority_workmanager</name> <fair-share-request-class> <name>low_priority</name> <fair-share>10</fair-share> </fair-share-request-class> </work-manager> <work-manager> <name>highpriority_workmanager</name> <fair-share-request-class> <name>high_priority</name> <fair-share>100</fair-share> </fair-share-request-class> </work-manager> <work-manager> <name>veryhighpriority_workmanager</name> <fair-share-request-class> <name>veryhigh_priority</name> <fair-share>1000</fair-share> </fair-share-request-class> </work-manager>
The EJBs in Example 2-6 are configured to get as many threads as there are instances of a resource they depend upon—a connection pool, and an application-scoped connection pool.
Example 2-6 weblogic-ejb-jar.xml with Connection Pool Based Max Thread Constraint
<weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.6/weblogic-ejb-jar.xsd"> <weblogic-enterprise-bean> <ejb-name>ResourceConstraintEJB</ejb-name> <jndi-name>core_work_ejb_resource_ResourceConstraintEJB</jndi-name> <dispatch-policy>test_resource</dispatch-policy> </weblogic-enterprise-bean> <weblogic-enterprise-bean> <ejb-name>AppScopedResourceConstraintEJB</ejb-name> <jndi-name>core_work_ejb_resource_AppScopedResourceConstraintEJB </jndi-name> <dispatch-policy>test_appscoped_resource</dispatch-policy> </weblogic-enterprise-bean> <work-manager> <name>test_resource</name> <max-threads-constraint> <name>pool_constraint</name> <pool-name>testPool</pool-name> </max-threads-constraint> </work-manager> <work-manager> <name>test_appscoped_resource</name> <max-threads-constraint> <name>appscoped_pool_constraint</name> <pool-name>AppScopedDataSource</pool-name> </max-threads-constraint> </work-manager> </weblogic-ejb-jar>
Example 2-7 weblogic-ejb-jar.xml with commonJ Work Managers
Example 2-8 weblogic-application.xml
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.7/weblogic-application.xsd"> <max-threads-constraint> <name>j2ee_maxthreads</name> <count>1</count> </max-threads-constraint> <min-threads-constraint> <name>j2ee_minthreads</name> count>1</count> </min-threads-constraint> <work-manager> <name>J2EEScopedWorkManager</name> </work-manager> </weblogic-application>
The Web application in Example 2-9 is deployed as part of the Enterprise application defined in Example 2-8. This Web application's descriptor defines two Work Managers. Both Work Managers point to the same max threads constraint,
j2ee_maxthreads, which is defined in the application's
weblogic-application.xml file. Each Work Manager specifies a different response time request class.
Example 2-9 Web Application Descriptor
<weblogic xmlns="http://xmlns.oracle.com/weblogic" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic http://xmlns.oracle.com/weblogic/1.0/weblogic.xsd"> <work-manager> <name>fast_response_time</name> <response-time-request-class> <name>fast_response_time</name> <goal-ms>2000</goal-ms> </response-time-request-class> <max-threads-constraint-name>j2ee_maxthreads </max-threads-constraint-name> </work-manager> <work-manager> <name>slow_response_time</name> <max-threads-constraint-name>j2ee_maxthreads </max-threads-constraint-name <response-time-request-class> <name>slow_response_time</name> <goal-ms>5000</goal-ms> </response-time-request-class> </work-manager> </weblogic>
The descriptor in Example 2-10 defines a Work Manager using the context-request-class.
Example 2-10 Web Application Descriptor
<?xml version="1.0" encoding="UTF-8"?> <weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.8/weblogic-web-app.xsd"> <work-manager> <name>foo-servlet-1</name> <request-class-name>test-fairshare2</request-class-name> <max-threads-constraint> <name>foo-mtc</name> <pool-name>oraclePool</pool-name> </max-threads-constraint> </work-manager> <work-manager> <name>foo-servlet</name> <context-request-class> <name>test-context</name> <context-case> <user-name>anonymous</user-name> <request-class-name>test-fairshare1</request-class-name> </context-case> <context-case> <group-name>everyone</group-name> </context-request-class> </work-manager> </weblogic-web-app>
Learn how to enable backward compatibility with Execute Queues and how to migrate applications from using Execute Queues to Work Managers.
WebLogic Server, Version 8.1, implemented Execute Queues to handle thread management in which you created thread-pools to determine how workload was handled. WebLogic Server still provides Execute Queues for backward compatibility, primarily to facilitate application migration. However, when developing new applications, you should use Work Managers to perform thread management more efficiently.
You can enable Execute Queues in the following ways:
Using the command line option
Use81StyleExecuteQueues property via the Kernel MBean in
Enabling Execute Queues disables all Work Manager configuration and thread self tuning. Execute Queues behave exactly as they did in WebLogic Server 8.1.
When enabled, Work Managers are converted to Execute Queues based on the following rules:
If the Work Manager implements a minimum or maximum threads constraint, then an Execute Queue is created with the same name as the Work Manager. The thread count of the Execute Queue is based on the value defined in the constraint.
If the Work Manager does not implement any constraints, the global default Execute Queue is used.
When an application is migrated from WebLogic Server 8.1, any Execute Queues defined in the server configuration before migration will still be present. WebLogic Server does not automatically convert the Execute Queues to Work Managers.
When an 8.1 application implementing Execute Queues is deployed on WebLogic Server 9.x, the Execute Queues are created to handle thread management for requests. However, only those requests whose dispatch-policy maps to an Execute Queue will take advantage of this feature.
WorkManagerMBean is accessed in the runtime tree or configuration tree depending on how the Work Manager is accessed by an application.
If the Work Manager is defined at the module level, the WorkManagerRuntime MBean is available through the corresponding ComponentRuntimeMBean.
If a Work Manager is defined at the application level, then WorkManagerRuntime is available through ApplicationRuntime.
If a Work Manager is defined globally in
config.xml, each application creates its own instance of the Work Manager. Each application has its own corresponding WorkManagerRuntime available at the application level.
WebLogic Server Work Managers provide server-level configuration that allows administrators a way to set dispatch-policies to their servlets and EJBs. WebLogic Server provides a programmatic way of handling work from within an application by implementing the
commonj.timers packages of the CommonJ specification.
For specific information on the WebLogic Server implementation of CommonJ, see the CommonJ Javadocs.
The WebLogic Server implementation of CommonJ enables an application to break a single request task into multiple work items, and assign those work items to execute concurrently using multiple Work Managers configured in WebLogic Server. Applications that do not need to execute concurrent work items can also use configured Work Managers by referencing or creating Work Managers in their deployment descriptors or, for Java EE Connectors, using the JCA API.
The following are some differences between the WebLogic Server implementation and the CommonJ specification:
The RemoteWorkItem interface is an optional interface provided by the CommonJ specification and is not supported in WebLogic Server. WebLogic Server implements its own cluster load balancing and failover policies. Workload management is based on these policies.
WebLogic CommonJ timers behave differently than
java.util.Timer. When the execution is greater that twice the period, the WebLogic CommonJ timer will skip some periods to avoid falling further behind. The
java.util.Timer does not do this.
In a WebLogic Server environment, the
WorkListener.WorkRejected method is called when a thread becomes stuck.
Unlike WebLogic Server Work Managers, which can only be accessed from an application via dispatch policies, you can access CommonJ Work Managers directly from an application. The following code example demonstrates how to lookup a CommonJ Work Manager using JNDI:
InitialContext ic = new InitialContext(); commonj.work.WorkManager wm = (commonj.work.WorkManager)ic.lookup("java:comp/env/wm/myWM");
See CommonJ Javadocs.
You can map an externally defined CommonJ Work Manager to a WebLogic Server Work Manager. For example, if you have a CommonJ Work Manager defined in a descriptor,
ejb-jar.xml, for example, as:
<resource-ref> <res-ref-name>minthreads_workmanager</res-ref-name> <res-type>commonj.work.WorkManager</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref>
You can link this to a WebLogic Server Work Manager by ensuring that the
name element is identical in the WebLogic Server descriptor such as
<work-manager> <name>minthreads_workmanager</name> <min-threads-constraint> <count>5</count> </min-threads-constraint> </work-manager>
This procedure is similar for a resource-ref defined in
web.xml. The WebLogic Server Work Manager can be defined in either a module descriptor (
weblogic.xml, for example) or in the application descriptor (