prolic / HumusAmqp

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

cancel queue request on signal to prevent streams from blocking #58

Closed oqq closed 6 years ago

oqq commented 7 years ago

The amqp extension + library has its own mechanism to remove blocking for requests, if the signal handler is activated.

But the cancelation for requests was not called from this library, so i have moved some code around to get rid of that issue: closes #45

I am not sure about side effects, so please have an extra review round. ;)

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 92.686% when pulling 0e1b18f0e8ae27aeb587f64b1653b9d39ef29217 on oqq:features/interupt_running_consumers into e1f298debdfdf609c742258ccfee37c149dde57c on prolic:master.

prolic commented 7 years ago

@oqq see https://github.com/oqq/HumusAmqp/blob/0e1b18f0e8ae27aeb587f64b1653b9d39ef29217/src/AbstractConsumer.php#L182

this line is 100% blocking, so the shutdown method is never called, unless the block has been removed (f.e. by timeout or message came in)

oqq commented 7 years ago

This is not true for the php-amqplib package. See this File: https://github.com/php-amqplib/php-amqplib/blob/master/PhpAmqpLib/Wire/IO/StreamIO.php and search for canDispatchPcntlSignal.

How I said, this package handles this behavior already like a charm by endless looping requests without blocking. My provided patch works exactly how it should without any script wrapper. Please test it by your own.

prolic commented 6 years ago

manually merged into master