Command Queue Doctrine Bundle
, (*1)
Doctrine driver bundle for gendoria/command-queue-bundle
., (*2)
Bundle created in cooperation with Isobar Poland., (*3)
, (*4)
Installation
Step 0: Prerequisites
:warning: Before using this bundle, you should install and configure
gendoria/command-queue-bundle
and
doctrine/doctrine-bundle
., (*5)
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:, (*6)
$ composer require gendoria/command-queue-doctrine-bundle "dev-master"
This command requires you to have Composer installed globally, as explained
in the installation chapter
of the Composer documentation., (*7)
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:, (*8)
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Gendoria\CommandQueueDoctrineDriverBundle\GendoriaCommandQueueDoctrineDriverBundle(),
);
// ...
}
// ...
}
Gendoria Command Queue Bundle should also be enabled and configured., (*9)
Step 3: Add bundle configuration
The example bundle configuration looks as one below., (*10)
gendoria_command_queue_doctrine_driver:
drivers:
poolname:
serializer: '@gendoria_command_queue.serializer.jms'
doctrine_connection: default
poolname
key in drivers
section can be any valid string. It allows to create separate driver 'pools'
for command routing., (*11)
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)
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., (*14)
So for gendoria_command_queue_doctrine_driver.driver.poolname
, your configuration should look similar
to code below., (*15)
gendoria_command_queue:
...
pools:
...
poolname:
send_driver: '@gendoria_command_queue_doctrine_driver.driver.poolname'
Step 5: Create database schema
Bundle provides Symfony command to create appropriate database schema. To run it, type, (*16)
Symfony 2.x:, (*17)
$ app/console cmq:doctrine:schema-create
Symfony 3.x:, (*18)
$ bin/console cmq:doctrine:schema-create
This command will check your configuration for database connections and queue tables. If any of the tables
is missing in database, it will try to create it. The command will not touch existing tables,
so it is safe to run it multiple times., (*19)
On the other hand, it will not (at the moment) check database for schema changes and update them., (*20)
Usage
To start receiving commands for your pool, you have to start one rabbitmq bundle worker process., (*21)
The command to do that is, (*22)
Symfony 2.x:, (*23)
$ app/console cmq:worker:run doctrine.poolname
Symfony 3.x:, (*24)
$ bin/console cmq:worker:run doctrine.poolname
Where poolname
is the pool name you defined in pools
section of configuration., (*25)
You should use services like supervisord to control running and restarting your workers., (*26)