jurry/laravel-rabbitmq

RabbitMQ for Laravel & Lumen Frameworks
83
Install
composer require jurry/laravel-rabbitmq
Latest Version:1.2
License:MIT
Last Updated:Oct 25, 2023
Links: GitHub  ·  Packagist
Maintainer: wajdijurry

RabbitMQ Package for Laravel & Lumen Frameworks

Description:

Its purpose is to initiate workers (consumers) and to send "sync" and "async" requests to another queues or exchanges.


Installation

composer require jurry/laravel-rabbitmq

Usage

  1. Register this package into your AppServiceProvider:

    class AppServiceProvider {
        public function register()
        {
            ...
    
            $this->app->singleton(\Jurry\RabbitMQ\Handler\AmqpHandler::class, function () {
                return new \Jurry\RabbitMQ\Handler\AmqpHandler(
                    env('JURRY_RABBITMQ_HOST'), // host
                    env('JURRY_RABBITMQ_PORT'), // port
                    env('JURRY_RABBITMQ_USERNAME'), // username
                    env('JURRY_RABBITMQ_PASSWORD'), // password
                    '\App\Services', // classesNamespace, where the consumer will look for to process the message with targeted service class
                    [
                        'sync_queue' => [ // Sync queue options, will be used when declare the queue
                            'name' => 'stores_sync',
                            'message_ttl' => 10000,
                        ],
                        'async_queue' => [ // Async queue options, will be used when declare the queue
                            'name' => 'stores_async',
                            'message_ttl' => 10000,
                        ],
                    ]
                );
            });
        }
    }
    
    • You can change the parameters as wish you need
  2. Register your custom command by adding your created class to the $commands member inside the app/Console/Kernel.php file:

    class Kernel extends ConsoleKernel
    {
        /**
         * The Artisan commands provided by your application.
         *
         * @var array
         */
        protected $commands = [
            // ...
            \Jurry\RabbitMQ\Command\SyncConsumerCommand::class,
            \Jurry\RabbitMQ\Command\AsyncConsumerCommand::class,
        ];
    
        // ...
    
    }
    
    
  3. Start new workers:

    php artisan amqp:sync_worker
    php artisan amqp:async_worker
    

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

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

628,058,007 9,707
laravel/framework

The Laravel Framework.

576,155,700 34,907
laravel/tinker

Powerful REPL for the Laravel framework.

485,678,092 7,440