Skip to main content

Simple Example of a Failed Job and Restarting the Queue

Premium
3 min read

Let's talk about job failures: what happens when a job fails and what you can do about it.


Failed Laravel Job

Imagine the scenario: We have the same notification job, which would fire the email to admins. After starting the queue worker, it will be empty at first as there are no jobs in the queue, and it is waiting for the jobs.

After a user registers, a job is added to the queue and is processed successfully.

Let's change the code by adding a user's email to the mail view without passing it from the mail class.

resources/views/email/registered-user.blade.php:

Hi, a new user {{ $name }} {{ $email }} is registered.

When a worker is started again, and the user tries to register, the job status now is failed.

You have to stop and start the queue worker after code changes because queue:work loads the Laravel application into memory only once when it starts.

But how can you see the error? In the database, there is a table called

The Full Lesson is Only for Premium Members

Want to access all of our courses? (34 h 11 min)

You also get:

58 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.