8

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?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Yuusha
  • 175
  • 1
  • 3
  • 10

2 Answers2

19

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.

Estevão Lucas
  • 4,440
  • 34
  • 37
2

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

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

To:

Queue::failing(function($connection, $job)
The Alpha
  • 143,660
  • 29
  • 287
  • 307
Yuusha
  • 175
  • 1
  • 3
  • 10