Manual:Job queue/For developers

Registering a job
To use the to do your non-urgent jobs, you need to do these things:

Create a Job subclass
You need to create a class, that, given parameters and a Title, will perform your deferred updates

Add your Job class to the global list
Add the Job class to the global $wgJobClasses array. In extensions, this is usually done in the main extension file, e.g. . Make sure the key name is unique.

If your extension uses extension.json descriptor, you can use its section :

How to invoke a job
There is another function to push jobs,, which will be executed at the very end, hence after jobs pushed with.

Job queue type
A job queue type is the command name you give to the parent::__construct method of your job class; e.g., using the example above, that would be synchroniseThreadArticleData.

getQueueSizes
will return an array of all job queue types and their sizes.

getSize
While  is handy for analysing the entire job queue, for performance reasons, it’s best to use   when analysing a specific job type, which will only return the job queue size of that specific job type.

Pushing jobs
The primary function is, which selects the job queue corresponding to the job type. Depending on the job queue implementation (database or Redis) it will be pushed either through a Redis connection either as a deferrable update (database).

The lazy push function keeps in memory the jobs. At the end of the current execution (end of MediaWiki request and/or end of the current job execution) the jobs kept in memory are pushed, as the last deferrable update (of type AutoCommitUpdate). As a deferrable update, they are are pushed at the end of the current execution, and as an AutoCommitUpdate the jobs are pushed as a single database transaction. See  and   for details.

In CLI, note that deferrable updates (either from  (JobQueueDB implementation), either from  ) are directly executed if the database transaction flag  is free. See  and   for details.

When some jobs are pushed through  but never really pushed (and hence lost) the destructor of JobQueueGroup shows a warning in the debug log. See phabricator:T100085 for an example of

