From cd0dcb5489e232c43366e008951aeb7e6dfb02a8 Mon Sep 17 00:00:00 2001 From: Lars Lauger Date: Mon, 20 Apr 2020 11:17:59 +0200 Subject: [PATCH] FEATURE: Allow configuration of RabbitMq heartbeat --- Classes/Queue/RabbitQueue.php | 20 ++++++++++++++++++-- README.md | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Classes/Queue/RabbitQueue.php b/Classes/Queue/RabbitQueue.php index 2a989d7..1b8173f 100644 --- a/Classes/Queue/RabbitQueue.php +++ b/Classes/Queue/RabbitQueue.php @@ -70,8 +70,24 @@ public function __construct(string $name, array $options = []) $vhost = $clientOptions['vhost'] ?? '/'; $insist = isset($clientOptions['insist']) ? (bool) $clientOptions['insist'] : false; $loginMethod = isset($clientOptions['loginMethod']) ? (string) $clientOptions['loginMethod'] : 'AMQPLAIN'; - - $this->connection = new AMQPStreamConnection($host, $port, $username, $password, $vhost, $insist, $loginMethod, null, 'en_US', 3.0, 3.0, null, true, 0); + $heartbeat = (int) ($clientOptions['heartbeat'] ?? 0); + + $this->connection = new AMQPStreamConnection( + $host, + $port, + $username, + $password, + $vhost, + $insist, + $loginMethod, + null, + 'en_US', + 3.0, + 3.0, + null, + true, + $heartbeat + ); $this->channel = $this->connection->channel(); // a worker should only get one message at a time diff --git a/README.md b/README.md index 09e85fb..0712c3a 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ Flowpack: port: 5672 username: guest password: guest + heartbeat: 60 # Sets RabbitMQ connection heartbeat to 60 seconds queues: producer-import: