PHP code example of randika-srimal / queue-manager

1. Go to this page and download the library: Download randika-srimal/queue-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

randika-srimal / queue-manager example snippets




return [
    'workers' => [
        [
            'connection' => 'database',
            'queue' => 'default',
            'processes' => 3,
            'memory' => 128,  // Maximum memory in MB before restart
            'timeout' => 60,  // Maximum execution time per job in seconds
            'sleep' => 3,     // Seconds to sleep when no jobs available
            'tries' => 3,     // Number of times to attempt a job
        ],
        [
            'connection' => 'redis',
            'queue' => 'high-priority,default',
            'processes' => 5,
            'memory' => 256,
            'timeout' => 60,
            'sleep' => 1,
            'tries' => 3,
        ],
    ],

    'memory_check_interval' => 30, // How often to check memory (seconds)
    'restart_delay' => 2,          // Delay before restarting a worker (seconds)
];

'workers' => [
    [
        'connection' => 'database',
        'queue' => 'default',
        'processes' => 3,
        'memory' => 128,
        'timeout' => 60,
        'sleep' => 3,
        'tries' => 3,
    ],
    [
        'connection' => 'database',
        'queue' => 'emails',
        'processes' => 2,
        'memory' => 128,
        'timeout' => 120,
        'sleep' => 5,
        'tries' => 2,
    ],
],

'workers' => [
    [
        'connection' => 'redis',
        'queue' => 'high-priority,default,low-priority',
        'processes' => 5,
        'memory' => 256,
        'timeout' => 60,
        'sleep' => 1,
        'tries' => 3,
    ],
],
bash
php artisan vendor:publish --tag=queue-manager-config
bash
php artisan queue:manage
bash
php artisan queue:manage --no-restart