提交 8994d2f0 编写于 作者: weixin_47267244's avatar weixin_47267244

修复 AMQP 消费者心跳设置为 0 时,自动设置 30s 心跳

上级 bebcdd50
......@@ -10,6 +10,7 @@ use Imi\AMQP\Contract\IMessage;
use Imi\AMQP\Enum\ConsumerResult;
use Imi\Log\Log;
use Imi\Util\Imi;
use ReflectionProperty;
use function Yurun\Swoole\Coroutine\goWait;
......@@ -45,9 +46,16 @@ abstract class BaseConsumer implements IConsumer
$this->declareConsumer();
$this->bindConsumer();
$messageCount = $this->messageCount;
$connection = $this->channel->getConnection();
if ($connection->getHeartbeat() <= 0)
{
$propertyReflection = new ReflectionProperty($connection, 'heartbeat');
$propertyReflection->setAccessible(true);
$propertyReflection->setValue($connection, 30);
}
while ($this->running && $this->channel && $this->channel->is_consuming())
{
$this->channel->getConnection()->checkHeartBeat();
$connection->checkHeartBeat();
$this->channel->wait(null, true);
if ($messageCount == $this->messageCount)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册