Job chaining in Lumen 5.5: withChain() not working how can I make it work?

浪子不回头ぞ 提交于 2019-12-24 11:51:42

问题


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

Queue::push(new ExampleJob);

or

dispatch(new ExampleJob);

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

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).

How do I chain Jobs in Lumen 5.5?


回答1:


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;

Most notably is this one:

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

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



来源:https://stackoverflow.com/questions/47308381/job-chaining-in-lumen-5-5-withchain-not-working-how-can-i-make-it-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!