我正在寻求帮助,我正在使用RabbitMQ的队列,我已经安装了vladimir-yuldashev/laravel-queue-rabbitmq
并且一切正常,但最近我开始遇到一些错误,这真的很奇怪,因为它有时会发生。
它抛出
local.ERROR:异常'ErrorException',消息'explode()期望参数2为字符串,在/ home / ubuntu / workspace / frontend / vendor / laravel / framework / src / Illuminate / Queue / Jobs中给出的数组/Job.php:165,
我从Illuminate\Queue\Jobs\Job
检查函数parseJob,并转储参数$job
,有时会收到类似Illuminate\Queue\CallQueuedHandler@call
的字符串,但其他人会收到类似
{
"__PHP_Incomplete_Class_Name":"App\\Jobs\\SendPost",
"log":[],
"post": {
"class":"App\\Models\\Post",
"id":72
},
"start":1491338912.0843,
"connection":null,
"queue":"front_send_post_0",
"delay":null
}
这是我的课程:
namespace App\Jobs;
class CheckSendPost implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
const TOTAL_QUEUES = 3;
public function handle()
{
try {
$posts = Post::getRedyToPost(date('Y-m-d H:i'), null, 0);
$count = 0;
Log::info('front_check_send_post: ' . count($posts));
if (count($posts)) {
foreach($posts as $post) {
dispatch(
(new \App\Jobs\SendPost($post))
->onQueue('front_send_post_' . ($count%self::TOTAL_QUEUES))
);
$count++;
}
}
dispatch(
(new \App\Jobs\CheckSendPost)
->onQueue('front_check_send_post')
);
} catch (\Exception $e) {
Log::info('ERROR ' . $e->getCode() . ': ' . $e->getMessage());
}
}
}
namespace App\Jobs;
class SendPost implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
public $post = null;
public $start = null;
public function __construct(Post $post)
{
$this->post = $post;
$this->start = microtime(true);
}
public function handle()
{
Log::info('Post: '.$this->post->id);
try {
$this->post->publish();
$this->post->setSuccess();
} catch (\Exception $e) {
$this->post->setError();
} finally {
$this->post->save();
}
Log::info(
date('d-m-Y H:i:s').', '.
round((microtime(true) - $this->start), 4).' seg, '.
'Mem '.Helper::formatBytes(memory_get_usage()).', '.
'Max Mem '.Helper::formatBytes(memory_get_peak_usage())
);
}
}
并使用
感谢您的帮助。
答案 0 :(得分:0)
检查您的命名空间是否正确。
__PHP_Incomplete_Class_Name
表示在反序列化时未找到该类。请参阅问题:__PHP_Incomplete_Class_Name wrong