About Thread Jobs
  • 20 Jun 2024
  • 3 Minutes to read
  • Dark
    Light

About Thread Jobs

  • Dark
    Light

Article summary

Thread Job allows a task to be run in the background without interfering with the user's work process. Thread Jobs don't consume too many resources because they use a thread, a part of a computer system that allows code to be scheduled and executed independently of its parent process. This allows multiple threads to be run simultaneously.


Single vs. Multi-Processing

In computing, a process involves executing a task or action using single or multiple threads. Multi-processing refers to a system's ability to manage multiple processors to share executing a task. Decisions utilizes a server's multi-core architecture to distribute the processing of tasks.

The diagram below compares single and multi-processes with single and multi-threads.  

What is a Thread Job?

A Thread Job is an implementation of controlling what a thread does.

A ThreadJobQueue is a grouping of Thread Jobs. Each Thread Job within the ThreadJobQueue is executed in a specified order. Each ThreadJobQueue is based on a priority (low, high, default, etc.). A ThreadJobQueue is single-threaded, but multiple queues can be run in parallel by providing unique names for each queue.

Thread Jobs are managed and run from the ThreadJobService. They are added to a ThreadJobQueue and await their turn to run. Thread Jobs run on a separate thread within the same process and are not added to the Decisions database. Since they run on a separate thread, this allows multiple Thread Jobs to run simultaneously, like in multi-threaded processes. Multi-threading is when a system executes multiple threads simultaneously and is independent of the parent process. 

In multi-node environments, Thread Jobs are not shared across the cluster. If it is started on one server, it will execute and stay on that specific server. The Load Balancer ensures each server has its specific Thread Job Queue(s) and Thread Jobs.

Common Use Cases of Thread Jobs

Since Thread Jobs can be run in the background, there are multiple ways they can be implemented. Below are some common use cases:

  • Syncing an OAuth Token 
  • Data Cleanup 
  • Reviewing an extensive loan application list 
  • Archiving data from a defined data source
  • Clearing a cache
  • Database Syncing from an external connection
  • Sending notification to groups/users of outstanding work or data updates

Decisions has several Thread Jobs by default to do tasks such as recording client statistics and reviewing the cache for expired items.

Running a Thread Job With Async Steps

Thread Jobs allow a task to run in the background without user interaction. Thread Jobs can be executed from a Flow using a Run Behavior (ThreadJobAsync, Work Queue ) via the Run Flows for List, and Run Flows For List [Batch Processing] steps, the Start Linked Flow Async sub Flow step, or from the Thread Jobs Report.

The Run Flows For List and Start Linked Flow Async step allows users to execute a multi-threaded Flow Behavior. These steps can be configured to run asynchronously to allow the parent Flow to run while the step completes a task. 

Defining a Custom Thread Job Queue

The following example demonstrates how to create a Thread Job Queue using the Start Linked Flow Async step inside of a Flow.

  1. In a Flow, navigate to DESIGNER ENTITIES > FLOWS and attach a Start Linked Flow Async step. 
  2. On the Properties panel, select the Manage Execution Threads option. Enter a name in the ThreadJobName field and a number in the ThreadCount field.
  3. Click PICK OR CREATE FLOW and pick/create a Flow. After a Flow is chosen or created, the name of the step will change to the name of that Flow.
  4. Connect the Done path to the next step in the Flow. When the Flow is debugged or run, the specified ThreadJobQuue will be created.

Viewing Thread Job Queues

  1. Navigate to System > Administration > System Tools and select Event Viewer. In v8.5+, users can also navigate to System > Jobs and Events > Scheduled Jobs. and select Thread Jobs.
  2. Click MORE and select Thread Jobs.
  3. A list of all active Thread Jobs will display. Some Thread Jobs within a queue will have an action menu if you right-click on it to run or clear the job.


For further information on Administration, visit the Decisions Forum.


 


Was this article helpful?