1

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?

Blackbam
  • 17,496
  • 26
  • 97
  • 150
  • Possible solution here: https://stackoverflow.com/questions/59199476/how-to-dispatch-chained-jobs-to-a-queue-in-lumen-6/59369832 – Derrick Miller Jan 31 '20 at 01:53

1 Answers1

2

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.

racl101
  • 3,760
  • 4
  • 34
  • 33
  • In my case, I needed to move quickly, so I just decided to use Laravel 5.5 instead, in spite of its added overhead. But I can confirm that the chaining jobs happens to work as advertised on Laravel 5.5 – racl101 Jan 13 '18 at 20:41
  • 1
    As per the [Lumen Queue doc's](https://lumen.laravel.com/docs/5.5/queues), you can dispatch a job (without the need for the Dispatchable trait) by simply calling `dispatch(new ExampleJob);`. – alexkb Jan 04 '19 at 03:03