mikemadisonweb / yii2-rabbitmq

RabbitMQ Extension for Yii2
MIT License
72 stars 32 forks source link

Error during instantiating producer #16

Closed miholeus closed 7 years ago

miholeus commented 7 years ago

I have config

'rabbitmq' => [
            'class' => 'mikemadisonweb\rabbitmq\Configuration',
            'connections' => [
                'default' => $params['rabbitmq']
            ],
            'producers' => [
                'queue_dispatcher' => [
                    'connection' => 'default',
                    'exchange_options' => [
                        'name' => 'queue.exchange',
                        'type' => 'topic',
                    ],
                ],
            ],

In my controller I'm trying to get producer

$producer = \Yii::$container->get(sprintf(BaseRabbitMQ::PRODUCER_SERVICE_NAME, 'queue_dispatcher'));

And I get error

Class rabbit_mq.producer.queue_dispatcher does not exist

How can I get producer instance? Why producer is not registered in container?

miholeus commented 7 years ago

I've figured out that I need to call $configuration->load(). That's embarrasing a little. I think it can not be done more elegant due to poor realization of di on yii :(