Configuration

Job Configuration

Configuration is done per-job via protected properties:

use WPZylos\Framework\Queue\Job;

class MyJob extends Job
{
    // Maximum number of attempts before marking as failed
    protected int $tries = 3;

    // Seconds to wait before retrying a failed attempt
    protected int $retryAfter = 60;

    // Maximum execution time in seconds (uses set_time_limit)
    protected int $timeout = 60;

    // Queue name for routing/prioritization
    protected string $queue = 'default';

    public function handle(): void
    {
        // job logic
    }
}

Property Reference

PropertyTypeDefaultDescription
$triesint3After this many failed attempts, the job is moved to the failures table
$retryAfterint60Delay in seconds before the job becomes available for the next attempt
$timeoutint60Calls set_time_limit() before execution (if available)
$queuestring'default'Logical queue name; use different names for priority routing

Cron Configuration

Batch Size

Control how many jobs are processed per WP-Cron invocation:

$cron = $app->make(QueueCronHandler::class);
$cron->setBatchSize(25); // Default: 10

Schedule Interval

The cron handler registers a custom "every minute" schedule. This is the minimum interval supported by WP-Cron. The actual execution frequency depends on site traffic (WP-Cron is triggered by page visits).

For more reliable cron execution, add a system cron job:

* * * * * wget -q -O /dev/null https://yoursite.com/wp-cron.php?doing_wp_cron

And disable the default WP-Cron in wp-config.php:

define('DISABLE_WP_CRON', true);

Queue Names

Use queue names to organize and prioritize jobs:

Queue NameUse CaseSuggested Batch Size
defaultGeneral-purpose jobs10
emailsEmail sending20
reportsReport generation5
urgentTime-sensitive tasks25
lowLow-priority background tasks3

Process specific queues with the worker:

$worker = $app->make(Worker::class);

// Process urgent first, then default
$worker->run(25, 'urgent');
$worker->run(10, 'default');
$worker->run(3, 'low');

Database Table Prefix

Table names are generated by ContextInterface::tableName(), which typically prepends the WordPress table prefix and your plugin prefix:

wp_myplugin_queue_jobs
wp_myplugin_queue_failures

The exact prefix depends on your plugin's context configuration.