You can install this package via composer using this command:
composer require plsys/distrbution-queue
The package will automatically register itself.
- Add repo:
"repositories": [
{
"type": "git",
"url": "https://github.com/kieutrungvtr/distribution.git"
}
]
- Add require:
"plsys/distrbution-queue": "dev-master"
- Run composer:
composer require plsys/distrbution-queue
Config to config/distribution.php:
This is the minimal config for the Distribution queue to work.
Add service provider: config/app.php
PLSys\DistrbutionQueue\DistributionServiceProvider::class
Vendor publish:
php artisan vendor:publish --provider="PLSys\DistrbutionQueue\DistributionServiceProvider" --tag=views
php artisan vendor:publish --provider="PLSys\DistrbutionQueue\DistributionServiceProvider" --tag=migrations
Migration and template for the Distribution queue to work.
- Create tables for the Distribution queue:
php artisan migrate
- Create
DistributionPullDesignProvideDataCommandclass andPullDesignJobclass.
Note: Queue name will be base on job name. Ex: Job name is PullDesignJob => Queue name: pull_design.
php artisan distribution:create-job PullDesign
- Put your logic code into the predefined file.
Starting with 8.0, this package supports Laravel Horizon out of the box. Firstly,
install Horizon and then set RABBITMQ_WORKER to horizon.
'connections' => [
// ...
'rabbitmq' => [
// ...
/* Set to "horizon" if you wish to use Laravel Horizon. */
'worker' => env('RABBITMQ_WORKER', 'default'),
],
// ...
],Config:
'defaults' => [
'supervisor-pull-design' => [
'connection' => 'rabbitmq',
'queue' => 'pull_design',
'balance' => 'auto',
'autoScalingStrategy' => 'time',
'maxProcesses' => env('HORIZON_WORKER_MAX_PROCESS', 10),
'maxTime' => 0,
'maxJobs' => 0,
'memory' => 128,
'tries' => env('HORIZON_WORKER_TRIES', 3),
'timeout' => env('HORIZON_WORKER_TIME_OUT', 240),
'nice' => 0,
],
'supervisor-pull-product' => [
'connection' => 'rabbitmq',
'queue' => 'pull_product',
'balance' => 'auto',
'autoScalingStrategy' => 'time',
'maxProcesses' => env('HORIZON_WORKER_MAX_PROCESS', 10),
'maxTime' => 0,
'maxJobs' => 0,
'memory' => 128,
'tries' => env('HORIZON_WORKER_TRIES', 3),
'timeout' => env('HORIZON_WORKER_TIME_OUT', 240),
'nice' => 0,
],
],
'environments' => [
'production' => [
'supervisor-pull-design' => [
'minProcesses' => env('HORIZON_WORKER_MIN_PROCESS', 1),
'maxProcesses' => env('HORIZON_WORKER_MAX_PROCESS', 10),
]
],
'local' => [
'supervisor-pull-design' => [
'minProcesses' => env('HORIZON_WORKER_MIN_PROCESS', 1),
'maxProcesses' => env('HORIZON_WORKER_MAX_PROCESS', 10),
],
'supervisor-pull-product' => [
'minProcesses' => env('HORIZON_WORKER_MIN_PROCESS', 1),
'maxProcesses' => env('HORIZON_WORKER_MAX_PROCESS', 10),
]
],
],