Queue Processor and Job Scheduler in Pega

What is Background processing in Pega?

Executing tasks in the background allows for improved scalability and performance. 
As we are famous on Agents for background processing to send emails, performing some tasks on the Work objects and queuing items, etc,

Pega has provided below two Rules to accommodate background processing instead of Agents, were 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 in the SysAdmin category in Pega.

How they can replace Agents?

Queue Processor: Queue processor rules replace standard agents for queue management and asynchronous processing.
We can choose between 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 standard queue processor rules are insufficient when deferring a task to a period of low utilization or when additional threads are required to achieve high 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 an advanced agent.

Queue Processor: Queue objects then process them.

How to configure Queue processor rule in Pega?

Queue processor rule in pega

1. When to process. We can configure from "Processing nodes settings" in the Queue processor rule.

First, we need to decide whether a Queue processor immediately runs when the object is queued or whether the run will be delayed.

2. Scaling. the number of processing threads to allocate to the task and number of times to attempt the task.
 
Vertical scaling: number of threads.
Horizontal scaling: number of nodes.
Each thread will be assigned on each node of the specified node type.
Note: 20 is the maximum number of threads across an entire cluster.

Node type: Classifying a node based on the interaction that the node supports.

For example, We can classify one node as "background processing" to perform background tasks and can classify other nodes for user interactions.

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

For example, if you have three nodes for background processing and you set the number of threads to 3, then you have nine threads for background processing.

3. Standard or Dedicated Queue rule.

While calling or referring queue processor rule in other rules, we can choose between Standard or Dedicated queue. 
Parameters will be changed for Standard and Dedicated queue processor.

Standard Queue: Specify the activity, choose the locking option, and access the group (optional) to specify the context.
Dedicated Queue: Specify the queue processor, choose the locking option, and access the group (optional) to specify the context.

We can call or refer queue processor rule in below two ways:

1. Activity: by using the "Queue-For-Processing" method.



2. Run in background smart shape in a flow rule: From the case designer life cycle also, we can choose it from Automation.

What happens when queue processing fails?

Queue processors can fail to process items correctly for several reasons. 
For example, the processes are unable to obtain a lock on an entry because they lack security access, or activity or related class is named incorrectly.

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

The system also reverses any changes the process initiated.
queue processor fail

How to monitor Queue processor rules?

In the Pega Admin studio, we can trace and monitor queue processor rules on 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 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 results of tracing to identify and fix issues with queue processor rules.

how to trace queue processor in admin studio


We can even view more data for the queue processor by clicking on "View data flow".
We can view run warnings, duration, start time, number of processed records, and average processing time.
data flow for queue processor

How to configure Job Scheduler in Pega?

Job scheduler rules from 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 to run the tasks on all selected nodes in the cluster or only one of the nodes.
3. Specifying the Schedule for the task to run, Scheduling options are Startup, Repeating, and Periodic.
    a. Repeating - For example every 2 days.
    b. Periodic -for example 2nd Sunday of every month.
3,4. Select the time and time zone to start the Scheduler if Daily, Weekly, Monthly, or Yearly.
5. Specify the context for the class and activity. Generally, will specify the Admin access group.
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 processes are unable to obtain a lock on an entry because they lack security access, or activity or related class is named incorrectly.
We can manage the Job Scheduler rules in the Admin studio where we can trace.

job scheduler in admin studio

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 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 a corresponding agent:
              Click Records > SysAdmin > Agents in Dev studio.
              Select the agent.
              Clear the Enabled check box of the agent that you want to disable.
              Click Save.



5 comments: