Laravel无法将作业排队


Laravel Unable to Queue Job

当我尝试将作业推送到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的事实有关?当我尝试使用serialize模型时,我只是得到一个未定义的属性$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作业执行良好

在我的例子中,这是因为作业表有一个有效负载"0"

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