Skip to content

Configuration ​

Set options under the Queue key in config/app.php or app_local.php. For a separate file, create config/app_queue.php returning an array, then load it in bootstrap with Configure::load('app_queue').

php
return [
    'Queue' => [
        'workerLifetime' => 60,
        'defaultRequeueTimeout' => 600,
        'defaultJobRetries' => 1,
        'sleeptime' => 10,
        'maxworkers' => 1,
    ],
];

The example configuration contains suggested overrides. It is not loaded automatically, and some values differ from the runtime defaults below.

Worker settings ​

KeyRuntime defaultMeaning
workerLifetime120 on the current branchSeconds before a worker exits between jobs
workerLifetimeJitter0Random seconds added to a bounded lifetime
workerPhpTimeoutTwice the worker lifetimeValue passed to PHP set_time_limit()
defaultRequeueTimeout600Default task claim timeout in seconds
defaultJobRetries1Retries after the first attempt
sleeptime10Seconds to sleep when no eligible job exists
maxworkers1Concurrent workers allowed per server; zero disables this cap
exitwhennothingtodofalseExit after the first empty poll
gcprob10Probability setting for cleanup between loop iterations
staleHeartbeatThreshold90Seconds before a worker heartbeat is treated as stale
cleanuptimeout2592000Retention for completed jobs; zero keeps them
cleanupAbortedTimeout0Retention after an aborted job's last fetch; zero keeps it
multiserverfalseEnable coordination across servers
connectiondefaultQueue datasource when no named connection is selected
connections[]Whitelist enabling multi-connection mode with two or more names
logfalse when unsetEmit informational worker logs
captureOutputSchema detectionCapture task output when the output column exists
maxOutputSize65536Stored output cap in bytes; zero uses the default
canInterruptSleepfalseAllow worker wake-up signals

--max-runtime overrides the worker lifetime. A non-null CLI override also sets PHP's timeout to twice that value; zero removes both limits. Earlier releases may require explicit worker lifetime configuration. See Upgrading.

PHP's timeout is not a portable wall-clock limit: on Unix, time blocked in many I/O operations is excluded. Put timeouts on external calls and size task claim timeouts above the longest expected execution time.

Task settings ​

Tasks expose timeout, retries, rate, costs, and unique. Override them on the class or by task name:

php
return [
    'Queue' => [
        'defaultRequeueTimeout' => 600,
        'tasks' => [
            'Queue.ProgressExample' => [
                'timeout' => 300,
                'retries' => 2,
            ],
        ],
    ],
];

A task timeout is capped at defaultRequeueTimeout. Increase that global cap before increasing a task's timeout. A claim that expires while a worker is still running can be executed by another worker.

rate delays successive executions of a task within a worker; it is not a global concurrency cap. unique restricts concurrent execution of that task type. costs participates in the per-server worker cost budget. These controls do not replace application idempotency checks.

Discovery and admin ​

ignoredTasks excludes task classes from discovery; plugins adds task sources. skipExistenceCheck => true bypasses task existence checks when creating jobs, so invalid task names can remain unprocessed.

isSearchEnabled controls optional Search integration. isStatisticEnabled enables the optional statistics view. It is not named isStatsEnabled. See Admin for access, layout, and dashboard settings.

executeAllowedCommands is required for Queue.Execute when debug is disabled. See Execute before enabling command execution.

Released under the MIT License.