Package

Mxl Laravel Queue Rate Limit

Simple Laravel queue rate limiting

Package

mxl/laravel-queue-rate-limit

View on GitHub →

laravel-queue-rate-limit

Simple Laravel queue rate limiting

Installation

3.* versions are compatible only with Laravel 7+.

$ composer require mxl/laravel-queue-rate-limit

For Laravel 6 use 2.* versions:

$ composer require mxl/laravel-queue-rate-limit "^2.0"

For Laravel 5 use 1.* versions:

$ composer require mxl/laravel-queue-rate-limit "^1.0"

Laravel 5.5+ will use the auto-discovery feature to add MichaelLedin\LaravelQueueRateLimit\QueueServiceProvider::class to providers.

This package is not compatible with older Laravel versions.

Add rate limits to config/queue.php:

'rateLimits' => [
'mail' => [ // queue name
'allows' => 1, // 1 job
'every' => 5 // per 5 seconds
]
]

Usage

Make sure that you don't use sync connection when queueing jobs. See default property in config/queue.php.

Run queue worker:

$ php artisan queue:work --queue default,mail

Then push several jobs to default and mail queues:

Mail::queue(..., 'mail');
Mail::queue(..., 'mail');
Mail::queue(..., 'mail');
Mail::queue(..., 'default');
Mail::queue(..., 'default');

You'll see that only mail queue jobs will be rate limited while default queue jobs will run normally.

Disable logging

Extend QueueServiceProvider:

<?php
 
namespace App\Providers;
 
class QueueServiceProvider extends \MichaelLedin\LaravelQueueRateLimit\QueueServiceProvider
{
protected function registerLogger()
{
$this->app->singleton('queue.logger', function () {
return null;
});
}
}

Add it to providers array in config/app.php:

<?php
 
return [
// ...
'providers' => [
// Laravel Framework Service Providers
// ...
// Application Service Providers
// ...
App\Providers\QueueServiceProvider::class,
// ...
]
];

Maintainers

Other useful Laravel packages from the author

License

See the LICENSE file for details.

Mxl Laravel Queue Rate Limit Related Articles

Database Job Chains for Laravel image

Database Job Chains for Laravel

Read article
Laravel 8.11 Released image

Laravel 8.11 Released

Read article
Laravel 8.13 Released image

Laravel 8.13 Released

Read article
Laravel AI: Get Raw HTTP Responses and Rate Limits image

Laravel AI: Get Raw HTTP Responses and Rate Limits

Read article
Test Job Failures Precisely with Laravel's assertFailedWith Method image

Test Job Failures Precisely with Laravel's assertFailedWith Method

Read article
Fair Queue Distribution with Laravel Balanced Queue image

Fair Queue Distribution with Laravel Balanced Queue

Read article
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Pushsilver logo

Pushsilver

Pushsilver is simple invoicing for freelancers and small studios — send polished invoices, automate reminders, and get paid on time without the bloat.

Pushsilver
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing