Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel Exception explode()期望参数2是字符串,数组为/Queue/Jobs/Job.php:165_Laravel_Queue_Rabbitmq - Fatal编程技术网

Laravel Exception explode()期望参数2是字符串,数组为/Queue/Jobs/Job.php:165

Laravel Exception explode()期望参数2是字符串,数组为/Queue/Jobs/Job.php:165,laravel,queue,rabbitmq,Laravel,Queue,Rabbitmq,我正在寻求帮助,我正在使用RabbitMQ队列,我已经安装了vladimir yuldashev/laravel queue RabbitMQ,一切正常,但最近我开始出现一些错误,这真的很奇怪,因为它只是偶尔发生 它抛出 local.ERROR:exception'ErrorException'和消息'explode()期望参数2是字符串,数组在/home/ubuntu/workspace/frontend/vendor/laravel/framework/src/illighted/Queue

我正在寻求帮助,我正在使用RabbitMQ队列,我已经安装了
vladimir yuldashev/laravel queue RabbitMQ
,一切正常,但最近我开始出现一些错误,这真的很奇怪,因为它只是偶尔发生

它抛出

local.ERROR:exception'ErrorException'和消息'explode()期望参数2是字符串,数组在/home/ubuntu/workspace/frontend/vendor/laravel/framework/src/illighted/Queue/Jobs/Job.php:165中给出

我从
illighte\Queue\Jobs\Job
检查parseJob函数,并转储参数
$Job
,有时它会收到类似
illighte\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())
        );
    }
}
和使用

  • PHP版本5.6.29
  • Apache/2.4.7(Ubuntu)
  • 拉威尔5.3

感谢您的帮助。

检查您的名称空间是否正确

\u PHP\u complete\u Class\u Name
表示在未序列化类时未找到该类。见问题: