pierophp / laravel-queue-manager
Laravel Queue Manager
Installs: 2 344
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 2
Forks: 4
Open Issues: 0
Requires
- php: >=7.0.0
- illuminate/bus: ^5.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/database: ^5.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/http: ^5.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/queue: ^5.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/view: ^5.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- dev-master
- v0.0.66
- v0.0.65
- v0.0.64
- v0.0.63
- v0.0.62
- v0.0.61
- v0.0.60
- v0.0.59
- v0.0.58
- v0.0.57
- v0.0.56
- v0.0.55
- v0.0.54
- v0.0.53
- v0.0.52
- v0.0.51
- v0.0.50
- v0.0.49
- v0.0.48
- v0.0.47
- v0.0.46
- v0.0.45
- v0.0.44
- v0.0.43
- v0.0.42
- v0.0.41
- v0.0.40
- v0.0.39
- v0.0.38
- v0.0.37
- v0.0.36
- v0.0.35
- v0.0.34
- v0.0.33
- v0.0.32
- v0.0.31
- v0.0.30
- v0.0.29
- v0.0.28
- v0.0.27
- v0.0.25
- v0.0.24
- v0.0.23
- v0.0.22
- v0.0.21
- v0.0.20
- v0.0.19
- v0.0.18
- v0.0.17
- v0.0.16
- v0.0.15
- v0.0.14
- v0.0.13
- v0.0.12
- v0.0.11
- v0.0.10
- v0.0.9
- v0.0.8
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-fix_chained_queue_validation
- dev-chained_queue_by_request_params
- dev-add_config_on_queue_config
- dev-added_option_to_avoid_overlapping
- dev-added_server_name_filter
- dev-fix_lock
- dev-laravel54
This package is auto-updated.
Last update: 2024-10-19 01:19:08 UTC
README
The Laravel Queue Manager, manage the queue process worker.
It uses Supervisor as Process Control System.
It also has a scheduler system built-in.
Installation
Composer
$ composer require pierophp/laravel-queue-manager
Publish
$ php artisan vendor:publish --provider="LaravelQueueManager\Providers\LaravelQueueManagerServiceProvider"
Running the migration
If you have MySQL version before 5.7, change in the migration the field "schedule_config" from "json" to "text".
$ php artisan migrate
Adding the provider
You need to add the provider at the file config/app.php
LaravelQueueManager\Providers\LaravelQueueManagerServiceProvider::class,
Configuration
Generating a job
You need generate a class that extends LaravelQueueManager\AbstractJob.
It's necessary to implement 2 methods:
Dispatching a new job
You need create a new instance of your job and call the dispatch() method.
Or use the CLI:
$ php artisan queue-manager:generate-queue queue_name
You can set optional params too:
$ php artisan queue-manager:generate-queue queue_name foo=test,bar=test
Database
To the job work correctly, it is necessary generate a row in the queue_config table.
Config field example
{
"nextQueues":{
"onError":[
{
"url":"url/test",
"data":{
"param":value
},
"name":"QUEUE_NAME",
"method":"POST",
"service":"SERVICE",
"delay_seconds":1
},
{
"url":"url/test",
"data":{
"param":value
},
"name":"QUEUE_NAME",
"method":"GET",
"service":"SERVICE",
"delay_seconds":1
}
],
"onSuccess":[
{
"url":"url/test",
"data":{
"param":value
},
"name":"QUEUE_NAME",
"method":"POST",
"service":"SERVICE",
"delay_seconds":1
}
]
}
}
Config
At the queue_manager.php config file you can configure:
Showing all available jobs
$ php artisan queue-manager:show-jobs
Getting error events
You need add to your AppServiceProvider and log as you like:
$this->app['events']->listen(\LaravelQueueManager\Events\ScheduleError::class, function(\LaravelQueueManager\Events\ScheduleError $error){ // my code }); $this->app['events']->listen(\LaravelQueueManager\Events\DispatchQueueError::class, function(\LaravelQueueManager\Events\DispatchQueueError $error){ // my code });
Deploying
Supervisor config
You need configure a cron to run as root every minute to generate the supervisor config
$ php artisan queue-manager:generate-config
Scheduler
You need configure a cron to run every minute to generate the scheduler
$ php artisan schedule:run
Queue Restart
Every time you change the PHP code, it's necessary to restart the queues. Put this at your deploy script.
$ php artisan queue:restart
API Mode
Introduction
To easily scale your jobs machine, you can run the queues in API mode. An API is much more easy to apply auto-scale.
Configuration
In your route configuration file add:
$api->post('queue/process', 'LaravelQueueManager\Http\Controllers\QueueController@process');
Edit in your "queue_manager.php" config file the execute_as_api and api_url options.