Optimized amqp consumer which can stop safely. (#2662)

Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
Dleno 2020-10-21 11:04:27 +08:00 committed by GitHub
parent 27c5ce7837
commit 20710a40e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -6,6 +6,7 @@
## Optimized ## Optimized
- [#2662](https://github.com/hyperf/hyperf/pull/2662) Optimized amqp consumer which can stop safely.
- [#2690](https://github.com/hyperf/hyperf/pull/2690) Optimized `tracer` which ensure span finished and flushed. - [#2690](https://github.com/hyperf/hyperf/pull/2690) Optimized `tracer` which ensure span finished and flushed.
# v2.0.15 - 2020-10-19 # v2.0.15 - 2020-10-19

View File

@ -21,6 +21,7 @@ use Hyperf\Amqp\Message\MessageInterface;
use Hyperf\Amqp\Pool\PoolFactory; use Hyperf\Amqp\Pool\PoolFactory;
use Hyperf\Contract\ConfigInterface; use Hyperf\Contract\ConfigInterface;
use Hyperf\ExceptionHandler\Formatter\FormatterInterface; use Hyperf\ExceptionHandler\Formatter\FormatterInterface;
use Hyperf\Process\ProcessManager;
use Hyperf\Utils\Coroutine\Concurrent; use Hyperf\Utils\Coroutine\Concurrent;
use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Message\AMQPMessage;
@ -92,7 +93,7 @@ class Consumer extends Builder
); );
try { try {
while ($channel->is_consuming()) { while ($channel->is_consuming() && ProcessManager::isRunning()) {
$channel->wait(); $channel->wait();
} }
} catch (MaxConsumptionException $ex) { } catch (MaxConsumptionException $ex) {