Documentation

addBackgroundJob

public \Bitrix\Main\Application::addBackgroundJob(
    callable $job,
    array $args = [],
    int $priority
);

Method adds a background job, executed after passing content to browser. Non-static method.

Parameters

ParameterTypeDescriptionVersion
$jobсallableWhat to call.
$argsarrayArray with parameters to call $job.
$priorityintJob priority. Default value: \Bitrix\Main\Application::JOB_PRIORITY_NORMAL.

Priority values, available in class Application:

  • const JOB_PRIORITY_NORMAL = 100
  • const JOB_PRIORITY_LOW = 50

Example

Adding a check and agent launch (CAgent::CheckAgents()) in the background job.


\Bitrix\Main\Application::getInstance()->addBackgroundJob(
    ["CAgent", "CheckAgents"],
    [],
    \Bitrix\Main\Application::JOB_PRIORITY_LOW
);


© «Bitrix24», 2001-2024
Up