From 4fa8c74401442ce30c4b2ba02d214c9032fc7d75 Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Fri, 7 Feb 2025 10:51:16 +0100 Subject: [PATCH] amqp: allow to configure heartbeats --- src/Queue/Broker/AMQP.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Queue/Broker/AMQP.php b/src/Queue/Broker/AMQP.php index 8a5bc62..a8a299f 100644 --- a/src/Queue/Broker/AMQP.php +++ b/src/Queue/Broker/AMQP.php @@ -38,7 +38,8 @@ public function __construct( private readonly int $httpPort = 15672, private readonly ?string $user = null, private readonly ?string $password = null, - private readonly string $vhost = '/' + private readonly string $vhost = '/', + private readonly int $heartbeat = 0, ) { } @@ -177,7 +178,7 @@ public function getQueueSize(Queue $queue, bool $failedJobs = false): int private function withChannel(callable $callback): void { $createChannel = function (): AMQPChannel { - $connection = new AMQPStreamConnection($this->host, $this->port, $this->user, $this->password, $this->vhost); + $connection = new AMQPStreamConnection($this->host, $this->port, $this->user, $this->password, $this->vhost, heartbeat: $this->heartbeat); if (is_callable($this->connectionConfigHook)) { call_user_func($this->connectionConfigHook, $connection); }