Run Time 2:27Free
Before we write a single line of code, give me two minutes to provide a real-life illustration of queues and workers. We'll use the example of a pizza delivery restaurant.
Run Time 6:58
Now that you have a basic idea of what a queue is, let's dispatch our first job using Laravel. We'll also learn about delayed job execution, and when you might reach for it.
Run Time 8:16
Now that you understand how to dispatch a simple closure, let's next create a dedicated
Job class, while discussing serialization and daemons.
Run Time 1:18
We've learned how to use the global
dispatch() function, but there's an alternative option you should consider as well. By default, each
Job class includes a
Run Time 5:05
So far, we've reviewed the "happy path" for a job, but what if an error or exception is thrown along the way? If you don't specify a maximum number of tries for your queue worker, the job will retry over and over again. In this episode, we'll learn how to fix this by creating a "failed_jobs" table.
Run Time 6:54Free
When working with queues, it can often prove difficult to see what's happening. For example, how many jobs ran in the last hour? Did any of them fail? How many workers are running? And what about only the jobs that match a particular tag? Let's solve this by installing Laravel Horizon, a dashboard for your Redis-backed queues.
Run Time 7:33
In this episode, we'll review how to create multiple queue stacks and workers, as well as when and why you might do so.
Run Time 2:34
If you don't have much control over the environment your application runs in, you might consider using the database queue connection. With this approach, rather than using Redis or Memcached, your jobs will instead be stored and fetched from the database.
Run Time 12:49
Before we dig in to learn how Laravel dispatches jobs to the queue, we must first learn about pipelines. It's possible that you've never come across Laravel's
Pipeline API! It's a fluent interface for sending an object or piece of data through a series of "pipes," each of which has the opportunity to modify or verify it in some way.
Run Time 9:44
Now that you understand how pipelines work, let's dive into the Laravel source code to figure out what precisely happens when we call
Run Time 13:02
Source diving isn't always the most enjoyable thing in the world, but, nonetheless, it's an excellent way to improve your understanding of an API. In this episode, we'll learn what happens when a queued job is dispatched, as well as how the worker executes the job in a separate request.