PHP code example of jetea / queue
1. Go to this page and download the library: Download jetea/queue 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/ */
jetea / queue example snippets
use Jetea\Queue\Job;
class ExampleJob extends Job
{
/**
* @var string job queue name (beanstalkd tube)
*/
public $queue = 'default';
/**
* The "time to run" for all pushed jobs. (beanstalkd ttr, timeout)
*
* @var int 允许 worker 执行的最大秒数,超时 job 将会被 release 到 ready 状态.
*/
public $retry_after = 60;
/**
* The number of times the job may be attempted.
*
* @var int 最大尝试次数
*/
public $tries = 1;
/**
* @var array
*/
public $words;
public function __construct(array $words)
{
$this->words = $words;
}
public function handle()
{
var_export($this->words);
var_dump($this->retry_after, $this->tries);
// throw new \Exception('handle job with error...lol ^_^');
}
}