This article describes how the job queue works in Business Central. A job queue is basically an abstraction that uses the task scheduler from the platform to enable end users to view, create, or modify jobs that are set to run in the background. These jobs can be set to run on a recurring schedule.
For information about how users work with the job queue in the client, see Use Job Queues to Schedule Tasks.
Job queue flow
The following diagram illustrates the flow of the job queue:
How job queue works
This section describes the flow that a job queue goes through.
A job is run when the task scheduler's task is run. For more information, see Task scheduler - detailed flow.
Here's a general overview of the process:
- When a job queue is created and set to ready state, a scheduled task is created to run, but not before the Earliest Start Date/Time.
- When the scheduled task is picked up by the task scheduler to run, a new background session is started.
- The background session is run by the Job Queue Dispatcher codeunit:
It first checks whether the job should be run or rescheduled.
If the job shouldn't run, it's deleted. Or, in the case of an already running "Category Code", it's rescheduled.
The job queue entry is updated to the In-Progress state, and a job queue log entry is created.
The specified Object ID to Run is then started.
If an exception occurs, none of the subsequent steps in the Job Queue Dispatcher path will be run, but instead, the failure codeunit path will be run.
- The failure codeunit path runs as follows:
- An exception is raised and surfaced.
- The Job Queue Error Handler codeunit is run in a new background session.
- The job queue entry is updated to the Error state.
- The errors are saved by using Error Message Management.
- The job queue entry and job queue log entry are updated with the error.
- The job queue then either stays in the Error state or is rescheduled:
- It will stay in Error state if the Maximum No. of Attempts value has been exceeded and it's not a recurring job.
- It will be rescheduled if the Maximum No. of Attempts value hasn't been exceeded and it's a recurring job.
About job queue sessions and permissions
The session runs using the same user/credentials that are used when calling AL code. The user that is used is the user that sets the job to ready state. The user must have appropriate permissions to run the job queue and any other objects that are associated with the operation of the specified object.
For more information about assigning permissions, see Assign Permissions to Users and Groups in the business functionality help.
Monitor and troubleshoot
Business Central offers two ways to monitor the flow of job queues: Azure Application Insights and the Session Event table. These tools let you follow the execution of a job and investigate errors in failure codeunits.
You can set up Business Central to send telemetry traces to an Application Insights resource in Azure. Once set up, telemetry data will be sent to the resource as job queue moves through the flow. For more information, see:
Session Event Table
From the Business Central web client, you can open the Session Events table by adding
table=2000000111 to the URL. For example: https://businesscentral.dynamics.com/?table=2000000111.
Submit and view feedback for