2017-04-05 4 views
0

私は助けを求めています、私はRabbitMQでキューを使用しています。最近私はいくつかのエラーを出すようになりました。Laravel Exception explode()は、パラメータ2が文字列であることを期待しています。配列/ Illuminate/Queue/Jobs/Job.php:165

それは

local.ERROR: exception 'ErrorException' with message 'explode() expects parameter 2 to be string, array given' in /home/ubuntu/workspace/frontend/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:165,

が、私は時々それがIlluminate\Queue\[email protected]のような文字列を受け取り、Illuminate\Queue\Jobs\Jobから関数parseJobをチェックして、パラメータ$jobをダンプ投げるが、他は

{ 
    "__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の)
  • Laravel 5.3あなたの助けのための

感謝を使用。あなたの名前空間がすべて正しい

答えて

0

チェック。

__PHP_Incomplete_Class_Nameは、それがアンシリアライズされていたときに、クラスが見つからなかったことを示しています。質問を参照:__PHP_Incomplete_Class_Name wrong

関連する問題