cryptoman3 / safe-queue
A Laravel Doctrine friendly daemonising queue worker for Laravel
v3.1
2024-08-09 17:48 UTC
Requires
- php: ^7.4 || ^8.2 || ^8.3
- illuminate/queue: ^8.0 || ^9.0 || ^10.0 || ^11.0
- laravel-doctrine/orm: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- mockery/mockery: ^1.5
- phpunit/phpunit: ^8.5 || ^9.5 || ^11.0
This package is not auto-updated.
Last update: 2024-11-01 19:04:50 UTC
README
A Laravel Queue worker that's safe for use with Laravel Doctrine
When to use SafeQueue
- You use Laravel 6 or up
- You use Laravel Doctrine
- Devops say the CPU usage of
queue:listen
is unacceptable - You want to do
php artisan queue:work --daemon
without hitting cascadingEntityManager is closed
exceptions
Compatibility
How it Works
SafeQueue overrides a small piece of Laravel functionality to make the queue worker daemon safe for use with Doctrine. It makes sure that the worker exits if the EntityManager is closed after an exception. For good measure it also clears the EM before working each job.
Installation
Install using composer
composer require digbang/safe-queue
Once you've got the codez add the following to your service providers in app.php
Digbang\SafeQueue\DoctrineQueueProvider::class
Lumen
Create the config file config/safequeue.php
and load it: $app->configure('safequeue');
<?php
return [
/*
|--------------------------------------------------------------------------
| Worker Command Name
|--------------------------------------------------------------------------
|
| Configure the signature / name of the Work Command here. The default
| is to rename the command to 'doctrine:queue:work', however you can
| rename it to whatever you want by changing this value.
|
| To override the Laravel 'queue:work' command name just set this
| to a false value or 'queue:work'.
|
*/
'command_name' => 'doctrine:queue:work',
];
Usage
php artisan doctrine:queue:work connection --daemon --sleep=3 --tries=3 ...
All options are identical to Laravel's own queue:work
method.