|
5 | 5 | - [Queueing Closures](#queueing-closures)
|
6 | 6 | - [Running The Queue Listener](#running-the-queue-listener)
|
7 | 7 | - [Push Queues](#push-queues)
|
| 8 | +- [Failed Jobs](#failed-jobs) |
8 | 9 |
|
9 | 10 | <a name="configuration"></a>
|
10 | 11 | ## Configuration
|
@@ -184,3 +185,39 @@ Now, when you login to your Iron dashboard, you will see your new push queue, as
|
184 | 185 | });
|
185 | 186 |
|
186 | 187 | The `marshal` method will take care of firing the correct job handler class. To fire jobs onto the push queue, just use the same `Queue::push` method used for conventional queues.
|
| 188 | + |
| 189 | +<a name="failed-jobs"></a> |
| 190 | +## Failed Jobs |
| 191 | + |
| 192 | +Since things don't always go as planned, sometimes your queued jobs will fail. Don't worry, it happens to the best of us! Laravel includes a convenient way to specify the maximum number of times a job should be attempted. After a job has exceeded this amount of attempts, it will be inserted into a `failed_jobs` table. The failed jobs table name can be configured via the `app/config/queue.php` configuration file. |
| 193 | + |
| 194 | +To create a migration for the `failed_jobs` table, you may use the `queue:failed-table` command: |
| 195 | + |
| 196 | + php artisan queue:failed-table |
| 197 | + |
| 198 | +You can specify the maximum number of times a job should be attempted using the `--tries` switch on the `queue:listen` command: |
| 199 | + |
| 200 | + php artisan queue:listen connection-name --tries=3 |
| 201 | + |
| 202 | +If you would like to register an event that will be called when a queue job fails, you may use the `Queue::failing` method. This event is a great opportunity to notify your team via e-mail or [HipChat](https://www.hipchat.com). |
| 203 | + |
| 204 | + Queue::failing(function($job, $data) |
| 205 | + { |
| 206 | + // |
| 207 | + }); |
| 208 | + |
| 209 | +To view all of your failed jobs, you may use the `queue:failed` Artisan command: |
| 210 | + |
| 211 | + php artisan queue:failed |
| 212 | + |
| 213 | +The `queue:failed` command will list the job ID, connection, queue, and failure time. The job ID may be used to retry the failed job. For instance, to retry a failed job that has an ID of 5, the following command should be issued: |
| 214 | + |
| 215 | + php artisan queue:retry 5 |
| 216 | + |
| 217 | +If you would like to delete a failed job, you may use the `queue:forget` command: |
| 218 | + |
| 219 | + php artisan queue:forget 5 |
| 220 | + |
| 221 | +To delete all of your failed jobs, you may use the `queue:flush` command: |
| 222 | + |
| 223 | + php artisan queue:flush |
0 commit comments