aloware / fair-queue
Laravel package to provide fair consumption of jobs against multiple partitions.
Installs: 11 498
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 1
Open Issues: 0
Language:Vue
Requires
- php: ^7.1|^8.0
- illuminate/queue: ^5.7|^6.0|^7.0|^8.0|^9.0
- illuminate/support: ^5.7|^6.0|^7.0|^8.0|^9.0
- laravel/framework: ^5.7|^6.0|^7.0|^8.0|^9.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.0|^8.0|^9.0
- dev-master
- v1.48
- v1.47
- v1.46
- v1.45
- v1.44
- v1.43
- v1.42
- v1.41
- v1.40
- v1.39
- v1.38
- v1.37
- v1.36
- v1.35
- v1.34
- v1.33
- v1.32
- v1.31
- v1.30
- v1.29
- v1.28
- v1.27
- v1.26
- v1.25
- v1.24
- v1.23
- v1.22
- v1.21
- v1.20
- v1.19
- v1.18
- v1.17
- v1.16
- v1.15
- v1.14
- v1.13
- v1.12
- v1.11
- v1.10
- v1.9
- v1.8
- v1.7
- v1.6
- v1.5
- v1.4
- v1.3
- v1.2
- v1.1
- v1.0
- dev-add-stand-alone-authentication
This package is auto-updated.
Last update: 2024-12-14 09:12:12 UTC
README
Laravel package to provide fair consumption of jobs against multiple partitions.
Installation
composer require aloware/fair-queue
Assets
Run the following command to publish assets and config file:
php artisan fair-queue:publish
Usage
This package uses Redis as data storage. By default it uses default
redis connection. You may configure to use another connection within
the fair-queue config file or by setting in the environment file.
FAIR_QUEUE_REDIS_DB="default"
FAIR_QUEUE_KEY_PREFIX="fair-queue"
Now, you need to replace use Dispatchable;
with use FairDispatchable;
in the Job class you need fair consumption functionality.
<?php
namespace App\Jobs;
use Aloware\FairQueue\FairDispatchable;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ExampleJob implements ShouldQueue
{
use FairDispatchable, InteractsWithQueue, Queueable, SerializesModels;
...
You can partition your data using ->fairConsume()
at dispatch time
and let your queue jobs be consumed fairly among those partitions.
ExampleJob::dispatch()
->onConnection($connection)
->onQueue($queue)
->fairConsume($companyId);
Retries
That is very important to understand the mechanics of this package. You may understand that the FairSignalJob which has been sent to the queue instead of the original job has no idea about the exact job which is going to be processed after the signal is received by the consumer.
There is no guarantee that the same job will be selected to be processed by the same signal in case of failure/retry.
So the number of tries you configure on queue:work
command is not
effective. It is recommended to set it to the biggest number you
can imagine for max tries (ie. 10) and set the number of tries using
the fair queue's ->tries()
chain call.
ExampleJob::dispatch()
->onConnection($connection)
->onQueue($queue)
->fairConsume($companyId)
->tries(3);
Monitoring
Check out the dashboard to monitor queue partitions, jobs, etc.:
https://your.domain/fairqueue/dashboard
License
The MIT License (MIT). Please see License File for more information.