gendoria / command-queue-rabbitmq-bundle
RabbitMQ driver bundle for Gendoria Command Queue
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.5.0
- gendoria/command-queue: ~0.2.0
- gendoria/command-queue-bundle: ~0.2.0
- php-amqplib/rabbitmq-bundle: ~1.6
- psr/log: ~1.0
- symfony/console: ~2.7|~3.0
- symfony/dependency-injection: ~2.7|~3.0
- symfony/framework-bundle: ~2.7|~3.0
- symfony/monolog-bundle: ~2.4
- symfony/yaml: ~2.7|~3.0
Requires (Dev)
- doctrine/orm: ~2.2,>=2.2.3
- symfony/phpunit-bridge: >=2.7.0
This package is auto-updated.
Last update: 2024-11-27 04:56:56 UTC
README
RabbitMQ driver bundle for gendoria/command-queue-bundle
.
Bundle created in cooperation with Isobar Poland.
Installation
Step 0: Prerequisites
⚠️ Before using this bundle, you should install and configure
gendoria/command-queue-bundle
and
php-amqplib/rabbitmq-bundle
.
For RabbitMQ Bundle you are required to configure only the 'connections' section. All required producers and consumers are created automatically by this bundle.
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:
$ 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.
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:
<?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.
Step 3: Add bundle configuration
The example bundle configuration looks as one below.
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.
Some serializer drivers are provided by Gendoria Command Queue Bundle.
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.
Driver configuration consists of several fields, describing connection and worker details. One driver entry has following keys:
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.
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.
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.
So for gendoria_command_queue_rabbit_mq_driver.driver.poolname
, your configuration should look similar
to code below.
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.
$ app/console rabbitmq:setup-fabric
It is optional, if you start your consumers before starting sending commands to queue.
Usage
To start receiving commands for your pool, you have to start one rabbitmq bundle worker process.
The command to do that is:
$ app/console cmq:worker:run rmq.poolname
Where poolname
is the pool name you defined in pools
section of configuration.
For the configuration from step 3, it will look like that:
$ app/console cmq:worker:run poolname
You should use services like supervisord to control running and restarting your workers.