prolic / HumusAmqp

PHP 7.4 AMQP library
https://humusamqp.readthedocs.io/
MIT License
76 stars 17 forks source link

PhpAmqpLib PCNTLHeartbeatSender #100

Closed basz closed 3 years ago

basz commented 3 years ago

Since 2.12.0 of PhpAmqpLib an PCNTLHeartbeatSender was introduced. It seems to fix and issue of mine with long running (docker) processes where connections to rabbitMQ are being dropped when no messages are send for a longer period of time.

A quick test revealed to me that simple adding the following to the connection factory would enable the PCNTLHeartbeatSender.

                try {
                    $sender = new PCNTLHeartbeatSender($connection->getResource());
                    $sender->register();
                } catch (AMQPRuntimeException $exception) {
                    // ignore
                }

Now I m using a socket connection and am not sure if other connections would benefit also. Not familiar with those. Especially the lazy ones. So not sure if I could create a PR that adds them to all or only some specific ones. Please advise.

prolic commented 3 years ago

Reading through https://github.com/php-amqplib/php-amqplib/pull/815 I think it makes sense to enable this for all connections. I'd say let's put it into the options and make it configurable, whether or not to enable it. By default it should be disabled, as this might be a breaking change for someone.

basz commented 3 years ago

Yep ok. I'll add that then today or tomorrow. Thx!

prolic commented 3 years ago

resolved via https://github.com/prolic/HumusAmqp/pull/102