Laravel Queue Failed Jobs

24,264

Solution 1

Work on global php. Its causing an error, just changed following:

Queue::failing(function($connection, $job, $data)

To:

Queue::failing(function($connection, $job)

Solution 2

You should call queue:work with --tries param, for ex:

$ php artisan queue:work sqs --tries=1

Without this params, your job will never get failed.

But remember to config you failed table.

1) Create migration file:

$ php artisan queue:failed-table

2) Run migrate to create table

$ php artisan migrate

3) In queue.php you need to config you 'failed' table. Ex:

'failed' => array(
    'database' => 'pgsql', 'table' => 'failed_jobs',
),

Now, when the job gets failed, it will insert it into failed_jobs table.

Just run php artisan queue:failed to get the failed list.

Share:
24,264
Yuusha
Author by

Yuusha

Updated on July 19, 2022

Comments

  • Yuusha
    Yuusha almost 2 years

    I was trying to record some data from other table when the jobs fails. It works great in failed jobs table but I cant get the Queue::failing(function($connection, $job, $data) to work every time the job failed. I did try to put it in global.php but no luck.

    Another question is what does the $job return? An object or just the job id?