kirschbaum-development / laravel-queue-batch-retry by luisdalmolin

Package to retry failed jobs in batch using custom filters
232,182
50
15
Package Data
Maintainer Username: luisdalmolin
Maintainer Contact: luis.nh@gmail.com (Luis Dalmolin)
Package Create Date: 2020-07-03
Package Last Update: 2024-06-11
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:13:14
Package Statistics
Total Downloads: 232,182
Monthly Downloads: 3,495
Daily Downloads: 112
Total Stars: 50
Total Watchers: 15
Total Forks: 3
Total Open Issues: 0

Laravel Queue Batch Retry

Laravel Supported Versions Actions Status MIT Licensed Latest Version on Packagist Total Downloads

Laravel only allows you to retry one job per time or all of them when using the queue:retry command. This package gives you a few more options so you retry failed jobs in batches filtering to only the jobs you want.

Installation

You can install the package via composer:

composer require kirschbaum-development/laravel-queue-batch-retry

Usage

There's two different commands this package provides.

queue:failed:batch-retry

php artisan queue:failed:batch-retry --failed-after="2 days ago" --queue="default" --limit=10 --filter="CrawlWebsiteJob" --filter-by-exception="ModelNotFoundException"

--filter

The failed_jobs table is not really a structured table, so "searching" is basically a like condition on the payload condition. Using this option, depending on how many records you have, could be very slow since it will have to do a full table scan to find results. Hopefully, you don't have a lot of failed jobs, though.

php artisan queue:failed:batch-retry --filter="PublishDocumentJob"
php artisan queue:failed:batch-retry --filter="12234"

--filter-by-exception

Same as the --filter option, but for the exception column in the failed_jobs table. Using this option, depending on how many records you have, could be very slow since it will have to do a full table scan to find results.

php artisan queue:failed:batch-retry --filter-by-exception="ModelNotFoundException"
php artisan queue:failed:batch-retry --filter-by-exception="Error when creating directory"

--failed-after

This option filters failed_at column. So let's say you had a bunch of jobs that failed today because of some API error in one of the services you use. You can retry all the jobs that failed since "today".

php artisan queue:failed:batch-retry --failed-after="today"

--failed-before

Same as the failed-after, but looking at previous dates.

php artisan queue:failed:batch-retry --failed-before="yesterday"

--limit

In case you want to run in just a specific number of jobs.

php artisan queue:failed:batch-retry --limit=10

--dry-run

We always get afraid of screwing things up, right? You can run dry run the command and see what's going to be executed first.

php artisan queue:failed:batch-retry --dry-run

queue:failed:batch-delete

In case you simply want to clean up your failed jobs table, there's also a queue:failed:batch-delete command which works exactly the same as the queue:failed:batch-retry command. You can use the same filters and options provided by the retry command.


Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email luis@kirschbaumdevelopment.com or nathan@kirschbaumdevelopment.com instead of using the issue tracker.

Credits

Sponsorship

Development of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more about us or join us!

License

The MIT License (MIT). Please see License File for more information.