Queue Processor and Job Scheduler in Pega

What is Background Processing in Pega?

Executing tasks in the background allows for improved scalability and performance.

We are familiar with using Agents for background processing, such as sending emails, performing tasks on work objects, and queuing items.

Pega provides two rules to support background processing for scenarios that previously required Agents, such as service-level agreements, sending daily emails, or queuing items:

1. Queue Processor
2. Job Scheduler
Queue Processor and Job Scheduler in Pega

These rules are available in the SysAdmin category in Pega.

How Can They Replace Agents?

Queue Processor

Queue Processor rules replace standard Agents for queue management and asynchronous processing.

We can choose between two types of Queue Processor rules when queuing an item: Standard Queue Processor and Dedicated Queue Processor.

Standard Queue Processor

Used for simple queue management.

Dedicated Queue Processor

Used when a Standard Queue Processor is insufficient, such as when deferring a task to a period of low utilization or when additional threads are required to achieve higher throughput.

Job Scheduler

Job Scheduler rules replace advanced Agents for recurring or scheduled tasks, such as sending emails on weekdays.

Job Scheduler rules simplify item scheduling because you configure a single Job Scheduler rule instead of selecting a Standard Agent or Advanced Agent.

Queue Processor: Queue items are then processed by the Queue Processor.

How to Configure a Queue Processor Rule in Pega

Queue Processor rule in Pega

1. When to Process

We can configure when the Queue Processor runs from the Processing Nodes Settings section of the Queue Processor rule.

First, we need to decide whether the Queue Processor should run immediately when the object is queued or whether the run should be delayed.

2. Scaling

Scaling determines the number of processing threads allocated to the task and the number of times the system attempts the task.

Vertical scaling: Number of threads.

Horizontal scaling: Number of nodes.

Each thread is assigned on each node of the specified node type.

Note: 20 is the maximum number of threads across an entire cluster.

Node Type

Node type classifies a node based on the type of interaction that the node supports.

For example, we can classify one node as Background Processing to perform background tasks and classify other nodes for user interactions.

When you select the number of threads, this number is multiplied by the number of nodes.

Example: If you have three nodes for background processing and set the number of threads to 3, you have nine threads available for background processing.

3. Standard or Dedicated Queue Processor

While calling or referring to a Queue Processor rule from other rules, we can choose between Standard or Dedicated Queue Processor. The parameters differ between the two.

Standard Queue Processor: Specify the activity, choose the locking option, and specify the Access Group if required to provide the processing context.

Dedicated Queue Processor: Specify the Queue Processor, choose the locking option, and specify the Access Group if required to provide the processing context.

How to Call a Queue Processor Rule

We can call or refer to a Queue Processor rule in two ways:

1. Activity — Queue-For-Processing Method

From an Activity, we can use the Queue-For-Processing method to queue an item.

Calling Queue Processor in Pega

2. Run in Background Smart Shape

We can use the Run in Background Smart Shape in a Flow rule. From the Case Designer lifecycle, we can choose it from Automation.

Run in Background Smart Shape in Pega

What Happens When Queue Processing Fails?

Queue Processors can fail to process items correctly for several reasons.

For example:

The process may be unable to obtain a lock on an entry because it lacks the required security access, or the Activity or related class may be named incorrectly.

If the process fails and the system cannot commit a queue entry, the system puts the entry into a failure status and indicates that the process is broken.

The system also reverses any changes initiated by the process.

Queue Processor failure in Pega

How to Monitor Queue Processor Rules

In Pega Admin Studio, we can trace and monitor Queue Processor rules from the Queue Processor landing page.

We can see the number of Queue Processors and broken-item details on the Queue Processor tile.

Queue Processor in Pega Admin Studio

How to Trace Queue Processor Rules in Pega

From the Admin Studio Queue Processor landing page, we can trace, stop, and start Queue Processors.

We can analyze the tracing results to identify and fix issues with Queue Processor rules.

How to trace Queue Processor in Pega Admin Studio

We can also view more data for the Queue Processor by clicking View Data Flow.

We can view run warnings, duration, start time, number of processed records, and average processing time.

Data flow for Queue Processor in Pega

How to Configure Job Scheduler in Pega

Job Scheduler rules are used for periodic or recurring tasks. Create a Job Scheduler rule from the SysAdmin category.

How to configure Job Scheduler in Pega
1. Enable or disable the Job Scheduler.
2. Select whether the task should run on all selected nodes in the cluster or only one node.
3. Specify the schedule for the task. Scheduling options include Startup, Repeating, and Periodic.
a. Repeating — For example, every 2 days.
b. Periodic — For example, the second Sunday of every month.
4. Select the time and time zone to start the Scheduler for Daily, Weekly, Monthly, or Yearly schedules.
5. Specify the context for the class and Activity. Generally, the Admin Access Group is specified.
6. Specify the class and Activity to be executed by the Scheduler and pass parameters if required.

How to Manage Job Scheduler in Pega

Job Schedulers can fail to process items correctly for several reasons.

For example:

The process may be unable to obtain a lock on an entry because it lacks the required security access, or the Activity or related class may be named incorrectly.

We can manage Job Scheduler rules in Admin Studio, where we can also trace them.

Job Scheduler in Pega Admin Studio
Important:

Job Scheduler does not queue items. To troubleshoot issues with Job Scheduler processes, you can run a trace on the failing processes.

Job Scheduler from Pega Admin Studio

Replacing an Agent with a Job Scheduler Rule

We can replace an existing Advanced Agent with a Job Scheduler rule to execute scheduled tasks, such as updating a database of email addresses every day at a specific time.

  1. Create a Job Scheduler rule to execute a specific Activity.
  2. Disable the corresponding Agent.
To disable the Agent:
  1. Click Records > SysAdmin > Agents in Dev Studio.
  2. Select the Agent.
  3. Clear the Enabled check box for the Agent that you want to disable.
  4. Click Save.

Related Article

Thanks for reading this post. Hope it helps. Please share it with others 😀

5 comments: