6phere/horizon-wildcard-consumer

Extended Laravel Horizon providing listening dynamically added queues matched by wildcard.
3,757 1
Install
composer require 6phere/horizon-wildcard-consumer
Latest Version:v1.0.0
PHP:*
License:MIT
Last Updated:Aug 20, 2024
Links: GitHub  ·  Packagist
Maintainer: pablo.roman

Horizon Wildcard Consumer

This package allows you to listen queues added dynamically by having wildcard * in queue names in Horizon config file.

Installation

You can install the package via composer using the following command:

composer require 6phere/horizon-wildcard-consumer

Usage

This package provides single command to consume dynamically added queues:

php artisan horizon:wildcard-consume

Before running this command make sure you added wildcards to your supervisor in Horizon config file. This command works just like standard php artisan horizon command if you don't have any wildcards in config.

Example horizon config

config/horizon.php environments section (please notice * in queue names):

connection can be set to rabbitmq

'environments' => [
    'production' => [
        'supervisor-1' => [
            'connection' => 'redis',
            'queue' => ['default', 'user_*_notes', '*-bills'],
            'balance' => 'auto',
            'processes' => 10,
            'tries' => 3,
        ],
        'supervisor-2' => [
            'connection' => 'redis',
            'queue' => ['agent_*_calls', 'company_*_messages'],
            'balance' => 'auto',
            'processes' => 5,
            'tries' => 3,
        ]
    ]
]

Example config for RabbitMQ

Add RabbitMQ connection config to config/queue.php You can get example config from a package maintainer's repo https://github.com/vyuldashev/laravel-queue-rabbitmq/tree/v8.0

Example .env for Redis

QUEUE_CONNECTION=redis
QUEUE_OBSERVER_TIMEOUT=25

Example .env for RabbitMQ

QUEUE_CONNECTION=rabbitmq
QUEUE_OBSERVER_TIMEOUT=25
RABBITMQ_WORKER=horizon
RABBITMQ_API_URL=http://localhost:15672
RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672
RABBITMQ_LOGIN=admin
RABBITMQ_PASSWORD=admin
RABBITMQ_SSL=0
RABBITMQ_QUEUE=default
RABBITMQ_VHOST=/

For additional info refer https://github.com/vyuldashev/laravel-queue-rabbitmq/tree/v8.0

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
v1.0.0 * * MIT