Laravel queue error

I was trying to write some data from another table when work orders fail. It works fine on the failed jobs table, but I can't seem to get it to Queue::failing(function($connection, $job, $data)

work every time the job fails. I tried to put it in global.php

but no luck.

Another question: what $job

does it return ? Object or just job ID?

+3


source to share


2 answers


Work on global php

. This raises an error by just changing the following information:

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

      



To:

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

      

0


source


You have to call queue: to work with --tries param, for example:

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

      

Without these parameters, your work will never fail.

But don't forget to customize the error table.

1) Create a migration file:

$ php artisan queue:failed-table

      



2) Run migration to create table

$ php artisan migrate

      

3) In queue.php, you need to customize the error table. Example:

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

      

Now, when the job failed, it will be inserted into the fail_jobs table.

Just run php artisan queue:failed

to get the error list.

+5


source







All Articles