PHP code example of queues / queue-manager

1. Go to this page and download the library: Download queues/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/ */

    

queues / queue-manager example snippets


class LongJob extends \Queue\Job {
    public function run() {
        sleep(10);
        return $this->getData();
    }
    
}

$queue='MyQueue';
$context=array();
$newJob = new LongJob()
$queuemanager = new QueueManager($context, $queue);
$queuemanager->getQueue($name)->addJob($newJob);

$queuemanager->getRunner($name)->runJobs();

$queuemanager->getRunner($name)->loop();

$runner = $queuemanager->getRunner($name);
$runner->maxJobCount=1;

class MyAppJob extends \Queue\Job {
    public $connection;

    public function init($context=NULL) {
        $this->connecton=$context->get(\My\Connection::class);
    }
    
}