Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nette-rabbitmq as internal 'extension' #18

Closed
BigOHenry opened this issue Feb 21, 2019 · 1 comment
Closed

nette-rabbitmq as internal 'extension' #18

BigOHenry opened this issue Feb 21, 2019 · 1 comment

Comments

@BigOHenry
Copy link

BigOHenry commented Feb 21, 2019

Hello,
i have one problem with queue/consumer definition in config. If the configuration is in main config.neon (root/app/config/config.neon) everything is ok. But i need the configuration in different config (root/libs/Ext/src/DI/ext_config.neon). When i move it into 'extension' config it doesnt work:

Gamee\RabbitMQ\Producer\Exception\ProducerFactoryException
Producer [testProducer] does not exist

I have some parts of app like small extensions (root/libs).
All services (consumer and queue) is at the same config (ext_config.neon) like configuration.
Any way or ideas how this could work?
Thank you very much

// root/libs/Ext/src/DI/ext_config.neon
services:
	# rabbitMQ
	- Ext\RabbitMq\Consumer\TestConsumer
	- Ext\RabbitMq\Queue\TestQueue(@Gamee\RabbitMQ\Client::getProducer(testProducer))

rabbitmq:
    connections:
        default:
            user: guest
            password: guest
            host: localhost
            port: 5672

    queues:
        testQueue:
            connection: default
            autoCreate: true

    producers:
        testProducer:
            queue: testQueue
            contentType: application/json
            deliveryMode: 2 # Producer::DELIVERY_MODE_PERSISTENT

    consumers:
        testConsumer:
            queue: testQueue
            callback: [@Ext\RabbitMq\Consumer\TestConsumer, consume]
            qos:
                prefetchSize: 0
                prefetchCount: 10
// root/libs/Ext/src/DI/ExtExtension.php
<?php

namespace Ext\DI;

use Nette;

class ExtExtension extends Nette\DI\CompilerExtension {

    public function loadConfiguration() {

        $config = $this->loadFromFile(__DIR__ . '/ext_config.neon');
        $config = Nette\DI\Helpers::expand($config, $this->validateConfig($this->config));

        Nette\DI\Compiler::loadDefinitions(
            $this->getContainerBuilder(),
            $config['services'],
            $this->name
        );
    }
}
@BigOHenry
Copy link
Author

I solved it already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant