From 68dcc77daa118ae31ad8c5d486dd0e16ded96a76 Mon Sep 17 00:00:00 2001 From: Jonathon Hill Date: Mon, 18 Mar 2024 14:40:44 -0400 Subject: [PATCH] fix: redis redelivery_delay setting does not work When using the redis transport, RedisConsumer::processResult() creates the redelivered record prior to the RedisSubscription callback executing. The subscription callback attached with Enqueue\Consumption\QueueConsumer then invokes RedisConsumer::reject(). Calling acknowledge() deletes the redelivered record which was created earlier. Thus, we should not create a new record in reject() and we should only call acknowledge() if we do not wish to redeliver. I have tested and confirmed that this change fixes the issue. However, if there is a better solution, please advise. Resolves #1342 --- pkg/redis/RedisConsumer.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/pkg/redis/RedisConsumer.php b/pkg/redis/RedisConsumer.php index 9c93b642a..7e8b2d0ba 100644 --- a/pkg/redis/RedisConsumer.php +++ b/pkg/redis/RedisConsumer.php @@ -96,19 +96,8 @@ public function reject(Message $message, bool $requeue = false): void { InvalidMessageException::assertMessageInstanceOf($message, RedisMessage::class); - $this->acknowledge($message); - - if ($requeue) { - $message = $this->getContext()->getSerializer()->toMessage($message->getReservedKey()); - $message->setRedelivered(true); - - if ($message->getTimeToLive()) { - $message->setHeader('expires_at', time() + $message->getTimeToLive()); - } - - $payload = $this->getContext()->getSerializer()->toString($message); - - $this->getRedis()->lpush($this->queue->getName(), $payload); + if (!$requeue) { + $this->acknowledge($message); } }