Worker configuration

The use of the <worker> element in work-queue.xml is optional. However, in actual practice, it is necessary for there to be at least one <worker> element for each <work-queue> element for the work queue to operate properly. The <worker> element contains an instances attribute that has a default value of 1. Without a <worker> element to provide this default, the processing logic does not allocate any workers for the work queue.

All of the following attributes are optional.

Attribute

Description

instances

The number of workers to create. By default, PolicyCenter sets the values of this attribute to 1.

If a worker wakes up and detects work items, it checks out those work items from the work queue. If there are more work items than the value specified by the batchsize attribute, the worker starts another worker. Each new worker checks out up to the maximum batchsize number of work items. If there are more work items remaining, the new worker starts another worker. The creation of workers continues until the number of workers reaches the maximum limit of workers as specified by the instances attribute.

maxpollinterval

How often a worker wakes up automatically and queries for work items, even if the worker receives no notification. You might need to increase the value of maxpollinterval to prevent excessive numbers of queries for work items. The default value of maxpollinterval is 60,000 milliseconds.

throttleinterval

The delay between processing work items in milliseconds. The value controls how long the process sleeps. A value of 0 (zero) means worker tasks process work items as rapidly as possible. To reduce the CPU load, set the value of throttleinterval to a positive non-zero value.

batchsize

How many work items the worker attempts to check out while searching for more work items. Larger batch sizes are more efficient, but might not result in good load distribution. The default value for batchsize is 10.

env

The one or more environments in which this particular worker configuration is active. To specify multiple values for the env attribute, use a comma-separated list.

server

The serverid of the server on which this particular worker is active.

Example

Suppose that you want to create a worker with two instances on each server that has an assigned role of workqueue. You define this work in a manner similar to the following code:
  • <worker server="#workqueue" instances="2"/>

In this case, the designation #workqueue (with the hash mark) indicates a specific server role and not the server ID. The worker definition sets instances to 2. This action creates two instances of the designated worker on each application server with the workqueue role.

See also