The Laravel Queue Cancel Batch package provides a command to cancel a specific batch of queued jobs. If you run the command without any arguments, it will list current batches that have more than one pending job, are not finished, and have not been canceled.
You can select multiple batches from this list, or if you know the UUIDs of the batches you want to cancel, you can pass those to the command. Here are a few examples of the two ways you can run this command:
# Search for active batches and cancel one or more
php artisan queue:cancel-batch
┌ Select one or more batches to cancel ─────────────────────────┐
│ My Test Batch (44/56 completed jobs; started 3 seconds ago) │
│ My Test Batch 2 (12/56 completed jobs; started 1 second ago) │
└───────────────────────────────────────────────────────────────┘
# cancel a batch if you already have the batch ID
php artisan queue:cancel-batch 70045ad7-3279-4481-9b1e-012710f22221
That's it. That's the package. To get started with this package, you can install it via composer and use it with Laravel 10 and Laravel 11 at the time of writing:
composer require macbookandrew/laravel-queue-cancel-batch
The package source code is available on GitHub.
The post Cancel a Specific Batch of Queued Jobs With This Laravel Package appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Read more https://laravel-news.com/cancel-a-specific-batch-in-laravel