Skip to content

kirschbaum-development/laravel-queue-batch-retry

Repository files navigation

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"

--exclude-filter

This is exact same as --filter, except in reverse. It will search all the payloads and exclude those given in the parameter.

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

--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 [email protected] or [email protected] 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.

About

Package to retry failed jobs in batches using custom filters.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages