2017 © Pedro PelĂĄez
 

symfony-bundle command-queue-rabbitmq-bundle

RabbitMQ driver bundle for Gendoria Command Queue

image

gendoria/command-queue-rabbitmq-bundle

RabbitMQ driver bundle for Gendoria Command Queue

  • Monday, October 24, 2016
  • by TiS
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Command Queue RabbitMQ Bundle

Build Status Scrutinizer Code Quality Code Coverage Downloads Latest Stable Version, (*1)

RabbitMQ driver bundle for gendoria/command-queue-bundle., (*2)

Bundle created in cooperation with Isobar Poland., (*3)

Isobar Poland, (*4)

Installation

Step 0: Prerequisites

:warning: Before using this bundle, you should install and configure gendoria/command-queue-bundle and php-amqplib/rabbitmq-bundle., (*5)

For RabbitMQ Bundle you are required to configure only the 'connections' section. All required producers and consumers are created automatically by this bundle., (*6)

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*7)

$ composer require gendoria/command-queue-rabbitmq-bundle "~0.2.0"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*8)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*9)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Gendoria\CommandQueueRabbitMqDriverBundle\GendoriaCommandQueueRabbitMqDriverBundle(),
        );

        // ...
    }

    // ...
}

Gendoria Command Queue Bundle and php-amqplib/rabbitmq-bundle bundles should also be enabled and configured., (*10)

Step 3: Add bundle configuration

The example bundle configuration looks as one below., (*11)

gendoria_command_queue_rabbit_mq_driver:
    serializer: '@gendoria_command_queue.serializer.jms'
    drivers:
        poolname:
            rabbitmq_connection: default
            exchange_name: poolname-command-queue-bus
            consumer_name: poolname_command_queue_worker
            consumer_queue_name: poolname-command-queue-worker-consumer
            producer_name: poolname_command_queue

serializer parameter is used to specify serializer driver used by the driver. You should use jms or symfony driver here, where jms is preferred., (*12)

Some serializer drivers are provided by Gendoria Command Queue Bundle., (*13)

drivers key defines RabbitMQ command queue drivers. They can be then used by Gendoria Command Queue Bundle as pool drivers. For each Command Queue pool using RabbitMQ transport, one driver should be defined., (*14)

Driver configuration consists of several fields, describing connection and worker details. One driver entry has following keys:, (*15)

  • rabbitmq_connection - Connection name, as definned in rabbitmq bundle configuration.
  • exchange_name - Exchange name for RabbitMQ.
  • consumer_name - consumer name for RabbitMQ bundle.
  • consumer_queue_name - Queue name for RabbitMQ.
  • producer_name - Producer name for RabbitMQ bundle.

This bundle appends appropriate consumers and producers to php-amqplib/rabbitmq-bundle, so no additional consumer / producer configuration is needed., (*16)

For each defined driver, service gendoria_command_queue_rabbit_mq_driver.driver.driverName will be created, where driverName is the key in drivers configuration. So for above configuration, one service with ID gendoria_command_queue_rabbit_mq_driver.driver.poolname will be present., (*17)

Step 4: Add a driver to Command Queue Bundle configuration

For each command queue pool you want to use rabbitmq driver on, you should set it as send_driver., (*18)

So for gendoria_command_queue_rabbit_mq_driver.driver.poolname, your configuration should look similar to code below., (*19)

gendoria_command_queue:
    ...
    pools:
        ...
        poolname:
            send_driver: '@gendoria_command_queue_rabbit_mq_driver.driver.poolname'

Step 5: Setup RabbitMQ fabric

This step is done by php-amqplib/rabbitmq-bundle command., (*20)

$ app/console rabbitmq:setup-fabric

It is optional, if you start your consumers before starting sending commands to queue., (*21)

Usage

To start receiving commands for your pool, you have to start one rabbitmq bundle worker process., (*22)

The command to do that is:, (*23)

$ app/console cmq:worker:run rmq.poolname

Where poolname is the pool name you defined in pools section of configuration., (*24)

For the configuration from step 3, it will look like that:, (*25)

$ app/console cmq:worker:run poolname

You should use services like supervisord to control running and restarting your workers., (*26)

The Versions