N
N
Nikita Roschenko2016-07-21 18:59:11
symfony
Nikita Roschenko, 2016-07-21 18:59:11

How to include rabbitmq-bundle in your 3thd party bundle?

Good afternoon, I am writing my 3thd party bundle on Symfony 3, the meaning of which is to raise several queues and 1 rpc connection.
So in the bundle configuration folder there is a rabbit_mq.yml file with approximately the following content:

old_sound_rabbit_mq:
    consumers:
        search_index:
            connection: default
            exchange_options: {name: 'search-index', type: direct}
            queue_options: {name: 'search-index', durable: true}
            callback: search.queue_consumer.index_consumer
    rpc_servers:
        search:
            connection: default
            callback: search.queue_consumer.search_consumer

When I import this file into the app/config/config.yml file everything works fine. But when I try to connect it via DependencyInjection/Extension :
<?php

namespace SearchServerBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension as DependencyInjectionExtension;
use Symfony\Component\DependencyInjection\Loader;

/**
 * This is the class that loads and manages your bundle configuration.
 *
 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
 */
class Extension extends DependencyInjectionExtension
{
    /**
     * {@inheritdoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);
        
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('parameters.yml');
        $loader->load('services.yml');
        $loader->load('rabbit_mq.yml');
        
    }
}

Then I get this error:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]                                                                  
  There is no extension able to load the configuration for "old_sound_rabbit_mq" (in /home/vagrant/projects/general/src/SearchServerBundle/D  
  ependencyInjection/../Resources/config/rabbit_mq.yml). Looked for namespace "old_sound_rabbit_mq", found none

I already tried different options but I can't set up rabbit mq via DI. How can I do that? at least a link to an example of such a configuration. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2016-07-21
@Avillions

Your band should not "think" for another bundle and go to app/config/config.yml.
1. Or you take php-amqplib / php-amqplib dependencies in your gang and write a wrapper (in other words, create an analogue of RabbitMqBundle)
2. You do not touch the library and install RabbitMqBundle as a dependency and use it through the application config and common interfaces. (I will also add that the dependence of one bundle on another is bad)
3. You create a bundle and override RabbitMqBundle symfony.com/doc/current/cookbook/bundles/inheritan...
4. You override the RabbitMqBundle config when initializing bundles. symfony.com/doc/current/cookbook/bundles/prepend_e...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question