gendoria / command-queue-doctrine-bundle
Doctrine driver for Gendoria Command Queue
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.5.0
- doctrine/doctrine-bundle: ~1.2
- gendoria/command-queue: ~0.2.0
- gendoria/command-queue-bundle: ~0.2.0
- symfony/framework-bundle: ~2.7|~3.0
Requires (Dev)
- phpunit/dbunit: ^2.0
- phpunit/phpunit: >=4.8.0
- symfony/phpunit-bridge: >=2.7.0
This package is auto-updated.
Last update: 2024-11-27 04:55:42 UTC
README
Doctrine 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
doctrine/doctrine-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-doctrine-bundle "dev-master"
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\CommandQueueDoctrineDriverBundle\GendoriaCommandQueueDoctrineDriverBundle(), ); // ... } // ... }
Gendoria Command Queue Bundle should also be enabled and configured.
Step 3: Add bundle configuration
The example bundle configuration looks as one below.
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.
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.
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_doctrine_driver.driver.poolname
, your configuration should look similar
to code below.
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
Symfony 2.x:
$ app/console cmq:doctrine:schema-create
Symfony 3.x:
$ 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.
On the other hand, it will not (at the moment) check database for schema changes and update them.
Usage
To start receiving commands for your pool, you have to start one rabbitmq bundle worker process.
The command to do that is
Symfony 2.x:
$ app/console cmq:worker:run doctrine.poolname
Symfony 3.x:
$ bin/console cmq:worker:run doctrine.poolname
Where poolname
is the pool name you defined in pools
section of configuration.
You should use services like supervisord to control running and restarting your workers.