From 9f30211c0c88496297f880d0d73422b5436e8535 Mon Sep 17 00:00:00 2001 From: Lars Lauger Date: Mon, 14 Mar 2022 11:51:26 +0100 Subject: [PATCH] BUGFIX: Return null on timeout Resolves #18 --- Classes/Queue/RabbitQueue.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Classes/Queue/RabbitQueue.php b/Classes/Queue/RabbitQueue.php index 5ac1167..115f7af 100644 --- a/Classes/Queue/RabbitQueue.php +++ b/Classes/Queue/RabbitQueue.php @@ -10,6 +10,7 @@ use Neos\Utility\ObjectAccess; use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Connection\AMQPStreamConnection; +use PhpAmqpLib\Exception\AMQPTimeoutException; use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Wire\AMQPTable; @@ -325,7 +326,11 @@ protected function dequeue(bool $ack = true, ?int $timeout = null): ?Message }); while ($cache === null) { - $this->channel->wait(null, false, $timeout ?: 0); + try { + $this->channel->wait(null, false, $timeout ?: 0); + } catch (AMQPTimeoutException $e) { + return null; + } } $this->channel->basic_cancel($consumerTag);