本文整理汇总了PHP中Jobs::fail方法的典型用法代码示例。如果您正苦于以下问题:PHP Jobs::fail方法的具体用法?PHP Jobs::fail怎么用?PHP Jobs::fail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jobs
的用法示例。
在下文中一共展示了Jobs::fail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AMQPConnection
<?php
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/jobs.php';
use PhpAmqpLib\Connection\AMQPConnection;
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$Jobs = new Jobs();
$channel->queue_declare('jobs', false, false, false, false);
echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";
$callback = function ($msg) use($Jobs) {
$queue = json_decode($msg->body, true);
if (empty($queue['queue'])) {
$Jobs->fail('Queue name is required: { "queue": "{queue-name}", "data": "....." }');
}
$job_name = $queue['queue'];
if (!isset($Jobs->jobs[$job_name])) {
$job_file = './jobs/' . $job_name . '.php';
if (!file_exists($job_file)) {
$Jobs->fail('job file does not exist: ' . $job_file);
}
require_once $job_file;
if (!class_exists($job_name)) {
$Jobs->fail('queue (' . $job_name . ') does not exist in file: ' . $job_file);
}
if (!method_exists($job_name, 'perform')) {
$Jobs->fail('method (' . $job_name . '->perform) does not exist in file: ' . $job_file);
}
$Jobs->jobs[$job_name] = array('job' => new $job_name(), 'failed_count' => 0);
if (method_exists($job_name, 'setUp')) {
$Jobs->jobs[$job_name]['job']->setUp();