【问题标题】:Laravel Unable to Queue JobLaravel 无法排队作业
【发布时间】:2015-11-03 16:06:02
【问题描述】:

当我尝试将作业推送到我的 Laravel 队列时,我反复收到以下错误:

Argument 1 passed to Illuminate\Queue\Jobs\Job::resolveAndFire() must be of the type array, null given, called in /home/vagrant/Code/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php on line 53 and defined

我不知道出了什么问题,但我猜这与我没有使用 SerializesModel Trait 的事实有关?当我尝试使用序列化模型时,我只是得到一个未定义的属性 $directory 错误。

工作类别是:

/**
 * Class StoreFile
 * @package App\Jobs
 */
class StoreFile extends Job implements SelfHandling, ShouldQueue
{
    use InteractsWithQueue;

    /**
     * @param string $directory
     * @param string $filename
     * @param UploadedFile $file
     */
    public function __construct($directory, $filename, $file)
    {
        $this->directory = $directory;
        $this->filename = $filename;
        $this->file = $file;
    }

    /**
     * @param FileSystem $storage
     * @return boolean
     */
    public function handle(FileSystem $storage)
    {
        $path = $this->directory . $this->filename;
        $storage->disk('s3')->put($path, $this->file);

        return true;
    }
}

更新 我使用这个将另一个班级的作业排队:

$this->dispatch(new StoreFile($directory, rawurlencode($filename), file_get_contents($evidence)));

其中 $evidence 是 UploadedFile。我确定所有变量都设置为好像我删除了 ShouldQueue/InteractsWithQueue 作业执行良好

【问题讨论】:

  • 为什么不发布导致错误的代码?你怎么称呼这份工作? $目录设置了吗?为什么返回 true?
  • 从错误看来,它发生在您排队作业时,请发布一些 sn-p 您如何排队作业。
  • 感谢您的帮助,我已经更新了我的问题。也不知道我为什么要回归真实,认为那是一个意外
  • @ExoticChimp 你解决了这个问题吗?我有类似的问题,你会在这里贡献stackoverflow.com/questions/33917028/…
  • 你有运气吗?我也面临同样的问题。

标签: php laravel laravel-5 message-queue beanstalkd


【解决方案1】:

这个错误很容易解决。检查:可能是您将手动测试消息添加到队列中。所以,这条消息可能会破坏你的代码,因为它有另一个结构。

【讨论】:

    【解决方案2】:

    在我的情况下,这是因为作业表具有有效负载“0”而不是 JSON 来执行作业。

    【讨论】:

      猜你喜欢
      • 2015-12-26
      • 2021-02-16
      • 2021-07-03
      • 1970-01-01
      • 1970-01-01
      • 2016-09-12
      • 2013-12-28
      • 1970-01-01
      • 2016-03-24
      相关资源
      最近更新 更多