Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Queue Failed Jobs

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?

like image 599
Yuusha Avatar asked Sep 25 '14 04:09

Yuusha


2 Answers

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.

like image 131
Estevão Lucas Avatar answered Sep 28 '22 05:09

Estevão Lucas


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

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

To:

Queue::failing(function($connection, $job)
like image 24
Yuusha Avatar answered Sep 28 '22 06:09

Yuusha