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

Producers/Consumers etc. are not lazy #96

Open
func0der opened this issue Dec 21, 2020 · 1 comment
Open

Producers/Consumers etc. are not lazy #96

func0der opened this issue Dec 21, 2020 · 1 comment

Comments

@func0der
Copy link
Contributor

Hey there,

I tried the lazy connections. They seem to work fine.
What is not lazy are the producers and probably the consumers either.

Given I have the AMQP (library not extension) connection set up as lazy and my producers config in the DI container (laminas in this case) looks like this:

  'factories' => [
            EncryptionConnectionMarkerInterface::class => [
                \Humus\Amqp\Container\ConnectionFactory::class,
                EncryptionConnectionMarkerInterface::class,
            ],
   ],

I inject that specific producer into a class (console command in this case) and get the following error:

PHP Fatal error:  Uncaught PhpAmqpLib\Exception\AMQPConnectionClosedException: ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.(0, 0) in /var/www/current/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php:754
Stack trace:
#0 [internal function]: PhpAmqpLib\Connection\AbstractConnection->connection_close()
#1 /var/www/current/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(216): call_user_func()
#2 /var/www/current/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(373): PhpAmqpLib\Channel\AbstractChannel->dispatch()
#3 /var/www/current/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(264): PhpAmqpLib\Channel\AbstractChannel->wait()
#4 /var/www/current/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AMQPLazyConnection.php(23): PhpAmqpLib\Connection\AbstractConnection->connect()
#5 /var/www/current/www/vendor/prolic in /var/www/current/www/vendor/laminas/laminas-servicemanager/src/ServiceManager.php on line 772

Fatal error: Uncaught PhpAmqpLib\Exception\AMQPConnectionClosedException: ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.(0, 0) in /var/www/current/www/vendor/laminas/laminas-servicemanager/src/ServiceManager.php on line 772

Laminas\ServiceManager\Exception\ServiceNotCreatedException: Service with name "DocumentEncryptionProducerMarkerInterface" could not be created. Reason: ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.(0, 0) in /var/www/current/www/vendor/laminas/laminas-servicemanager/src/ServiceManager.php on line 772

Call Stack:
    0.0002     396384   1. {main}() /var/www/current/www/vendor/vvzf/console-wrapper/bin/mezzio-console:0
    0.0481    3208944   2. {closure:/var/www/current/www/vendor/vvzf/console-wrapper/bin/mezzio-console:27-38}() /var/www/current/www/vendor/vvzf/console-wrapper/bin/mezzio-console:38
    0.3607    6685696   3. Laminas\ServiceManager\ServiceManager->get($name = 'Symfony\\Component\\Console\\Application') /var/www/current/www/vendor/vvzf/console-wrapper/bin/mezzio-console:32
    0.3607    6685696   4. Laminas\ServiceManager\ServiceManager->doCreate($resolvedName = 'Symfony\\Component\\Console\\Application', $options = ???) /var/www/current/www/vendor/laminas/laminas-servicemanager/src/ServiceManager.php:201

The line that is referenced here is the referencing the ProducerFactory that tries to create a new channel, even though it does not have to at creation time.

When the channel is created the connection will initialize which makes the "Lazy" connection unlazy.

Am I using this feature wrong?
If not, what good is a lazy connection, if every other aspect of the library is eager? :D

Is there a plan to implement lazy producers/consumers/exchanges etc. that basically just trigger the connection if needed?

@func0der func0der changed the title Producers are not lazy Producers/Consumers etc. are not lazy Dec 21, 2020
@prolic
Copy link
Owner

prolic commented Dec 21, 2020

Thanks for the report. Right now I am very busy these days, I'll see if I can get to it soon.

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

No branches or pull requests

2 participants