流明5.5中的作业链接:withChain()不起作用如何使它起作用? [英] Job chaining in Lumen 5.5: withChain() not working how can I make it work?

查看:266
本文介绍了流明5.5中的作业链接:withChain()不起作用如何使它起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于分派单个作业,我通常执行以下操作之一:

For dispatching a single job I usually do one of these:

Queue::push(new ExampleJob);

dispatch(new ExampleJob);

https://lumen.laravel.com/docs/5.5/queues

根据Laravel文档,某个作业链是这样完成的:其中一个作业取决于前一个作业:

According to the Laravel Docs a certain Job chain, where one Job depends upon the previous is done like this:

ExampleJob::withChain([
    new OptimizePodcast,
    new ReleasePodcast
])->dispatch();

https://laravel.com/docs/5.5/queues#job-chaining

但是,这在流明中不起作用(此处存在类似问题:

However this does not workin in Lumen (similar problem here: How to dispatch a Job to a specific queue in Lumen 5.5).

如何在Lumen 5.5中链接Jobs?

How do I chain Jobs in Lumen 5.5?

推荐答案

鉴于Laravel 5.5文档中的示例,在我的

I don't think that will work given that in Laravel 5.5 documentation, in their example under creating jobs under the Queues documentation page, it shows that it requires several traits to able use all the features:

<?php

namespace App\Jobs;

use App\Podcast;
use App\AudioProcessor;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class ProcessPodcast implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $podcast;

最值得注意的是这个:

use Illuminate\Foundation\Bus\Dispatchable;似乎完全是Lumen 5.5框架中缺少的一个特征.

use Illuminate\Foundation\Bus\Dispatchable; which appears to be a trait that is missing from the Lumen 5.5 framework altogether.

其余的Illuminate\...特征似乎也包括在内.

The rest of the Illuminate\... traits seem to be included.

这篇关于流明5.5中的作业链接:withChain()不起作用如何使它起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆