Skip to content
 
 

Latest commit

 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distribution Queue (Rabbitmq, Horizon) for Laravel

Installation

You can install this package via composer using this command:

composer require plsys/distrbution-queue

The package will automatically register itself.

Un-official install

  1. Add repo:
"repositories": [
  {
    "type": "git",
    "url": "https://github.com/kieutrungvtr/distribution.git"
  }
]
  1. Add require:
"plsys/distrbution-queue": "dev-master"
  1. Run composer:
composer require plsys/distrbution-queue

Configuration

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.

Use your own Distribution Lib

  1. Create tables for the Distribution queue:
php artisan migrate
  1. Create DistributionPullDesignProvideDataCommand class and PullDesignJob class.

Note: Queue name will be base on job name. Ex: Job name is PullDesignJob => Queue name: pull_design.

php artisan distribution:create-job PullDesign
  1. Put your logic code into the predefined file.

Horizon support

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),
            ]
        ],
    ],

About

Support distribution queue for Laravel project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages