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