Skip to content

Commit

Permalink
Merge branch '2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed Jun 3, 2021
2 parents 564a8ee + 6f6e8f6 commit 6995691
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/AMQPConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class AMQPConnection extends AbstractConnection
*/
protected $channelManager;

/**
* @var bool
*/
protected $exited = false;

public function __construct(
string $user,
string $password,
Expand Down Expand Up @@ -141,7 +146,7 @@ public function channel($channel_id = null)
$this->channelManager->close($channel_id);
$this->channelManager->get($channel_id, true);

return parent::channel($channel_id); // TODO: Change the autogenerated stub
return parent::channel($channel_id);
}

public function getConfirmChannel(): AMQPChannel
Expand Down Expand Up @@ -209,7 +214,8 @@ protected function loop(): void
$this->channelManager->get($channel)->push([$frame_type, $payload], 0.001);
}
} catch (\Throwable $exception) {
$this->logger && $this->logger->error('Recv loop broken. The reason is ' . (string) $exception);
$level = $this->exited ? 'warning' : 'error';
$this->logger && $this->logger->log($level, 'Recv loop broken. The reason is ' . (string) $exception);
} finally {
$this->loop = false;
$this->close();
Expand Down Expand Up @@ -239,6 +245,8 @@ protected function heartbeat(): void
Coroutine::create(function () {
while (true) {
if (CoordinatorManager::until(Constants::WORKER_EXIT)->yield($this->getHeartbeat())) {
$this->exited = true;
$this->close();
break;
}

Expand Down

0 comments on commit 6995691

Please sign in to comment.