I
I
Ivan Lapshin2019-09-05 22:35:57
Laravel
Ivan Lapshin, 2019-09-05 22:35:57

How to call event after job execution?

Can't call event after job is done. What is written in the documentation does not work.
I call job in the controller:

class testController extends Controller
{
    public function test(){
        test::dispatch();
    }
}

The job itself:
class test implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function handle()
    {
       Log::info('dispatch test job');
    }
}

Inserted the code from the documentation into the AppServiceProvider
public function boot()
    {
        Queue::after(function ( JobProcessed $event ) {
            Log::info($event->connectionName);
        });
    }

The queue is running, you can see how the jobs are being processed, only "dispatch test job" appears in the locks.
Most likely I'm doing something wrong. I don’t know how to do it right, I can’t find an example anywhere, the only question on the topic was closed without an answer))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2019-09-05
@JhaoDa

The queue listener after "I pasted the code from the documentation into the AppServiceProvider" was not restarted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question