phplaravellaravel-5.5

What determines queue job status


Didn't find an answer for this question, but I might have not worded it properly. In that case, sorry.

I'm getting into Laravel's queued jobs to dispatch item deliveries in a game (basically boils down to sending a HTTP request and receiving a response). I ran into a wall though. How does Laravel determine whether a job has failed or succeeded? What exactly classifies it as failed?


Solution

    1. A job is considered failed if it throws an unhandled exception for every attempt to run the job. This is done in Worker::process which forwards exceptions to handleJobException which in turn calls markJobAsFailedIfWillExceedMaxAttempts.

    2. A job can use the InteractsWithQueue trait and call fail($exception = null) to signal that it has failed.